/**
 @file sys_usw_nexthop_debug.c

 @date 2009-12-28

 @version v2.0

 The file contains all nexthop module core logic
*/

/****************************************************************************
 *
* Header Files
*
****************************************************************************/
#include "ctc_const.h"
#include "ctc_error.h"
#include "ctc_linklist.h"
#include "sys_usw_common.h"
#include "sys_usw_opf.h"
#include "sys_usw_nexthop_api.h"
#include "sys_usw_nexthop.h"
#include "sys_usw_l3if.h"
#include "sys_usw_internal_port.h"
#include "sys_usw_aps.h"
#include "sys_usw_nexthop_hw.h"
#include "sys_usw_ftm.h"

#include "drv_api.h"

/****************************************************************************
 *
* Defines and Macros
* Mater branch
*****************************************************************************/

#define SYS_NH_DEBUG_DUMP_HW_TABLE(tbl_str, FMT, ...)              \
    do                                                       \
    {                                                        \
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "    "tbl_str "::");                                  \
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, FMT, ##__VA_ARGS__);                      \
    } while (0)

#define SYS_NH_DEBUG_TYPE_HEAD(type) " ~~~~~ DUMP "type " Nexthop ~~~~~~\n"

#define SYS_NH_DEBUG_NH_MERGE_MODE       "N/A"

#define NHID_CONVERT_STR(id, str)  (sal_sprintf(str, "%u", (id)))

extern void ctc_list_delete_list(struct ctc_linklist* list);
extern sys_usw_nh_api_master_t* p_usw_nh_api_master[CTC_MAX_LOCAL_CHIP_NUM_PP];

/****************************************************************************
 *
* Global and Declaration
*
*****************************************************************************/
extern sys_nh_db_srh_t*
_sys_usw_nh_lkup_srh_id(uint8 lchip, uint32 srh_id);

int32
sys_usw_nh_dump_xvlan(uint8 lchip, uint32 nhid, uint8 detail)
{
    sys_nh_info_com_t* p_nhinfo = NULL;
    int32 ret;
    uint32 cmd;
    uint8 is_dsnh8w = 0;
    DsNextHop8W_m   dsnh8w;
    uint32 index = 0;
    uint8 svlan_tag_dis = 0;
    uint8 tag_mode = 0;
    uint8 svlan_valid = 0;
    uint8 svlan_tagged = 0;
    uint8 payload_operation = 0;
    uint16 output_svlan = 0;
    uint8 cvlan_tag_dis = 0;
    uint8 cvlan_valid = 0;
    uint16 output_cvlan = 0;
    uint8 cvlan_share = 0;
    uint8 loop = 0;
    uint8 loop_cnt = 0;
    uint32 dsnh_offset = 0;
    uint8 share_type = 0;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid, &p_nhinfo));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }

    if (!detail)
    {
        return CTC_E_NONE;
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Vlan Edit \n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------\n");

    dsnh_offset = p_nhinfo->hdr.dsnh_offset;

    loop = 0;
    loop_cnt = 1;
    if (  CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_EN)
        && !CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_SHARE_DSNH))
    {
        loop_cnt = 2;
    }

    while ((loop++) < loop_cnt)
    {
    if (  CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_EN)
        && !CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_SHARE_DSNH))
        {
            if (loop == 1)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " ---------------------- :%s\n","W [W/P]");
            }
            else
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " ---------------------- :%s\n","P [W/P]");
                dsnh_offset = is_dsnh8w ? (dsnh_offset + 2) : (dsnh_offset + 1);
            }

        }

        is_dsnh8w = CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_USE_DSNH8W);

        if ( (dsnh_offset >> SYS_NH_DSNH_INTERNAL_SHIFT) == SYS_NH_DSNH_INTERNAL_BASE)
        {
            cmd = DRV_IOR(EpeNextHopInternal_t, DRV_ENTRY_FLAG);
            index = (dsnh_offset&((1 << SYS_NH_DSNH_INTERNAL_SHIFT) - 1))/2;
        }
        else
        {
            cmd = DRV_IOR(DsNextHop8W_t, DRV_ENTRY_FLAG);
            index = (dsnh_offset % 2)?(dsnh_offset - 1):dsnh_offset;
        }

        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &dsnh8w));

        if (!is_dsnh8w && (dsnh_offset % 2))
        {
            sal_memmove((uint8 *)&dsnh8w, (uint8 *)&dsnh8w + DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t), DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
        }


        share_type = GetDsNextHop8W(V, shareType_f,  &dsnh8w);
        svlan_tagged = GetDsNextHop8W(V, svlanTagged_f,  &dsnh8w);
        payload_operation = GetDsNextHop8W(V, payloadOperation_f,  &dsnh8w);

        if (is_dsnh8w || share_type == SYS_NH_SHARE_TYPE_VLANTAG)
        {
            svlan_tag_dis = GetDsNextHop8W(V, svlanTagDisable_f,  &dsnh8w);
            tag_mode      = GetDsNextHop8W(V, taggedMode_f,  &dsnh8w);
            svlan_valid   = GetDsNextHop8W(V, outputSvlanIdValid_f,  &dsnh8w);
            output_svlan  = GetDsNextHop8W(V, outputSvlanId_f,  &dsnh8w);

            cvlan_tag_dis = GetDsNextHop8W(V, cvlanTagDisable_f,  &dsnh8w);
            cvlan_share =  GetDsNextHop8W(V, ctagShareMode_f,  &dsnh8w);
            if (is_dsnh8w || (!cvlan_share))
            {
                cvlan_valid = GetDsNextHop8W(V, outputCvlanIdValid_f,  &dsnh8w);
                output_cvlan = GetDsNextHop8W(V, outputCvlanId_f,  &dsnh8w);
            }
        }
        else if(share_type == SYS_NH_SHARE_TYPE_L2EDIT_VLAN)
        {
            svlan_tag_dis = GetDsNextHop4W(V, u1_g4_svlanTagDisable_f, &dsnh8w);
            tag_mode = GetDsNextHop4W(V, u1_g4_taggedMode_f, &dsnh8w);
            svlan_valid = GetDsNextHop4W(V, u1_g4_outputSvlanIdValid_f, &dsnh8w);
            output_svlan = GetDsNextHop4W(V, u1_g4_outputSvlanId_f, &dsnh8w);
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :", "Svlan operation");
        if (!payload_operation)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "none");
        }
        else
        {
            if (svlan_tag_dis && cvlan_tag_dis && tag_mode)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "swap");
            }
            else if (svlan_tag_dis)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "none");
            }
            else if(!svlan_tagged)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "strip");
            }
            else if(tag_mode)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "add");
            }
            else if(svlan_valid)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "replace");
            }
            else
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "none");
            }
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%d\n", "Svlan id", output_svlan);


        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :", "Cvlan operation");
        if (!payload_operation)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "none");
        }
        else
        {
            if (svlan_tag_dis && cvlan_tag_dis && tag_mode)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "swap");
            }
            else if (cvlan_tag_dis)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "none");
            }
            else if(tag_mode)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "add");
            }
            else if(cvlan_valid)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "replace");
            }
            else
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "none");
            }
        }

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%d\n", "Cvlan id", output_cvlan);
    }



    return CTC_E_NONE;

}

int32
sys_usw_nh_dump_iloop(uint8 lchip, uint32 nhid, uint8 detail)
{
    sys_nh_info_brguc_t* p_brguc_info;
    sys_nh_info_com_t* p_nhinfo = NULL;

    int32 ret;
    DsFwd_m dsfwd;
    uint32 cmd;
    uint32 nhptr = 0;
    uint16 lport = 0;
    uint8 gchip = 0;
    char nh_str[50] = {0};

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid, &p_nhinfo));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_ILOOP != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't BridgeUC nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_brguc_info = (sys_nh_info_brguc_t*)(p_nhinfo);

    cmd = DRV_IOR(DsFwd_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, p_brguc_info->hdr.dsfwd_offset / 2, cmd, &dsfwd));

    nhptr = GetDsFwd(V, nextHopPtr_f, &dsfwd);
    if (DRV_FROM_AT(lchip))
    {
        lport = ((((nhptr >> 14)&0x1) << 8) | (nhptr&0xFF));
    }
    else if ((DRV_IS_TMM(lchip) || DRV_IS_TMG(lchip)))
    {
        lport = (nhptr&0xFF);
    }
    else
    {
        lport = ((((nhptr >> 16)&0x1) << 7) | (nhptr&0xFF));
    }
    CTC_ERROR_RETURN(sys_usw_get_gchip_id(lchip, &gchip));

    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "I-LOOP");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%-4x\n", SYS_MAP_DRV_LPORT_TO_CTC_GPORT(gchip, lport));

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_rspan(uint8 lchip, uint32 nhid, uint8 detail)
{
    sys_nh_info_rspan_t* p_rspan_info;
    sys_nh_info_com_t* p_nhinfo = NULL;

    int32 ret;
    uint32 cmd;

    DsNextHop4W_m   dsnh;
    DsNextHop8W_m   dsnh8w;
    uint32 dsnh_offset = 0;


    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_RSPAN != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't RSPAN nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_rspan_info = (sys_nh_info_rspan_t*)(p_nhinfo);

    dsnh_offset = p_rspan_info->hdr.dsfwd_offset;

    if (((dsnh_offset >> 4) & 0x3FFF) != SYS_NH_DSNH_INTERNAL_BASE)
    {
        cmd = DRV_IOR(DsNextHop4W_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, dsnh_offset, cmd, &dsnh));
    }
    else
    {
        cmd = DRV_IOR(EpeNextHopInternal_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (dsnh_offset & 0x2) >> 1, cmd, &dsnh8w));
        sal_memcpy((uint8*)&dsnh, ((uint8*)&dsnh8w + DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t) * (dsnh_offset & 0x1)), DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", nhid);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "RSPAN");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%u\n", GetDsNextHop4W(V, destVlanPtr_f, &dsnh));

    return CTC_E_NONE;
}
char *
_sys_usw_nh_dump_get_l2rewrite_desc(uint8 lchip, uint32 l2edit_ptr, uint8 is_inner)
{
    uint32 cmd = 0;
    uint8 rewrite_type = 0;
    ds0_t   l2edit;
    sal_memset(&l2edit, 0, sizeof(l2edit));
    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
    {
        cmd = DRV_IOR(DsL2EditEth3W_t, DRV_ENTRY_FLAG);
        DRV_IOCTL(lchip, l2edit_ptr, cmd, &l2edit);
        rewrite_type = GetDsL2EditEth3W(V, l2RewriteType_f, &l2edit);
        switch (rewrite_type)
        {
            case SYS_NH_L2EDIT_TYPE_LOOPBACK:
                return "DsL2EditLoopback";
            case SYS_NH_L2EDIT_TYPE_ETH_4W:
                return "DsL2EditEth3W";
            case SYS_NH_L2EDIT_TYPE_ETH_8W:
                return "DsL2EditEth6W";
            case SYS_NH_L2EDIT_TYPE_MAC_SWAP:
                return "DsL2EditSwap";
            case SYS_NH_L2EDIT_TYPE_FLEX_8W:
                return "DsL2EditFlex";
            case SYS_NH_L2EDIT_TYPE_PBB_4W:
                return "DsL2EditPbb4W";
            case SYS_NH_L2EDIT_TYPE_PBB_8W:
                return "DsL2EditPbb8W";
            case SYS_NH_L2EDIT_TYPE_OF:
                return "DsL2EditOf";
            case SYS_NH_L2EDIT_TYPE_INNER_SWAP:
                return "DsL2EditInnerSwap";
            case SYS_NH_L2EDIT_TYPE_INNNER_DS_LITE:
                return "DsL2EditDsLite";
            case SYS_NH_L2EDIT_TYPE_INNNER_DS_LITE_8W:
                return "DsL2EditDsLite6w";
            default :
                return "Error";
        }
    }
    else
    {
        if (DRV_FROM_AT(lchip) && is_inner)
        {
            cmd = DRV_IOR(DsL2EditAddEth1X0_t, DRV_ENTRY_FLAG);
        }
        else
        {
            cmd = DRV_IOR(DsL2EditAddEth1X_t, DRV_ENTRY_FLAG);
        }
        DRV_IOCTL(lchip, l2edit_ptr, cmd, &l2edit);
        rewrite_type = GetDsL2EditAddEth1X(V, l2EditType_f, &l2edit);
        if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_ADDETH1X))
        {
            return "DsL2EditAddEth1X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_ADDETH2X))
        {
            return "DsL2EditAddEth2X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_ADDRAW))
        {
            return "DsL2EditAddRaw";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_RWETH1X))
        {
            return "DsL2EditRwEth1X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_RWETH2X))
        {
            return "DsL2EditRwEth2X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_GEMPORT))
        {
            return "DsL2EditGemPort";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_LOOPBACK))
        {
            return "DsL2EditLoopback";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_AUTOETH1X))
        {
            return "DsL2EditAutoEth1X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_AUTOETH2X))
        {
            return "DsL2EditAutoEth2X";
        }
        else
        {
            return "Error";
        }
    }
}


char *
_sys_usw_nh_dump_get_l3rewrite_desc(uint8 lchip, uint32 l3edit_ptr, uint8 is_inner)
{
    uint32 cmd = 0;
    uint8 rewrite_type = 0;
    ds0_t   l3edit;
    sal_memset(&l3edit, 0, sizeof(l3edit));
    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
    {
        cmd = DRV_IOR(DsL3EditMpls3W_t, DRV_ENTRY_FLAG);
        DRV_IOCTL(lchip, l3edit_ptr, cmd, &l3edit);
        rewrite_type =  GetDsL3EditMpls3W(V, l3RewriteType_f, &l3edit);
        switch (rewrite_type)
        {
            case SYS_NH_L3EDIT_TYPE_MPLS_4W:
                return "DsL3EditMpls3W";
            case SYS_NH_L3EDIT_TYPE_NAT_4W:
                return "DsL3EditNat3W";
            case SYS_NH_L3EDIT_TYPE_NAT_8W:
                return "DsL3EditNat6W";
            case SYS_NH_L3EDIT_TYPE_TUNNEL_V4:
                return "DsL3EditTunnelV4";
            case SYS_NH_L3EDIT_TYPE_TUNNEL_V6:
                return "DsL3EditTunnelV6";
            case SYS_NH_L3EDIT_TYPE_L3FLEX:
                return "DsL3EditFlex";
            case SYS_NH_L3EDIT_TYPE_OF8W:
                return "DsL3EditOf6W";
            case SYS_NH_L3EDIT_TYPE_OF16W:
                return "DsL3EditOf12W";
            case SYS_NH_L3EDIT_TYPE_LOOPBACK:
                return "DsL3EditLoopback";
            case SYS_NH_L3EDIT_TYPE_TRILL:
                return "DsL3EditTrill";
            case SYS_NH_L3EDIT_TYPE_MPLS_12W:
            case SYS_NH_L3EDIT_TYPE_NONE:
                return "DsL3EditMpls12W";
            default :
                return "Error";
        }
    }
    else
    {
        if (DRV_FROM_AT(lchip) && is_inner)
        {
            cmd = DRV_IOR(DsL3EditAddMpls1X0_t, DRV_ENTRY_FLAG);
        }
        else
        {
            cmd = DRV_IOR(DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
        }
        DRV_IOCTL(lchip, l3edit_ptr, cmd, &l3edit);
        rewrite_type =  GetDsL3EditAddMpls1X(V, l3EditType_f, &l3edit);
        if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_ADDIP4))
        {
            return "DsL3EditAddIp4";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_ADDIP44X))
        {
            return "DsL3EditAddIp44X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_ADDIP6))
        {
            return "DsL3EditAddIp6";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_MPLS1X))
        {
            return "DsL3EditAddMpls1X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_MPLS2X))
        {
            return "DsL3EditAddMpls2X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_MPLS4X) || !rewrite_type)
        {
            return "DsL3EditAddMpls4X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_ADDRAW))
        {
            return "DsL3EditAddRaw";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_RWIP41X))
        {
            return "DsL3EditRwIp41X";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_RWIP4))
        {
            return "DsL3EditRwIp4";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_RWIP6))
        {
            return "DsL3EditRwIp6";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_LOOPBACK))
        {
            return "DsL3EditLoopback";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_ADDTRILL))
        {
            return "DsL3EditAddTrill";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_RWIP68X))
        {
            return "DsL3EditRwIp6Sr";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_ADDIP68X))
        {
            return "DsL3EditAddIp6Sr";
        }
        else if ((rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_INSFLEX))||(rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_INSFLEX8X)))
        {
            return "DsL3EditInsFlex";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_DELFLEX))
        {
            return "DsL3EditDelFlex";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_RWFLEX))
        {
            return "DsL3EditRwFlex";
        }
        else if (rewrite_type == DRV_ENUM(DRV_L3EDITTYPE_RWIP62X))
        {
            return "DsL3EditRwIp62X";
        }
        else
        {
            return "Error";
        }
    }

}

int32
_sys_usw_nh_dump_l2edit_outer(uint8 lchip, uint32 outer_edit_ptr)
{
    uint32 cmd  = 0;
    uint32 l2_rewrite_type = 0;
    ds0_t l2edit_out;
    uint8 use_spme = 0;

    sal_memset(&l2edit_out, 0 , sizeof(l2edit_out));

    if (outer_edit_ptr >= MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM))
    {
        outer_edit_ptr = outer_edit_ptr - MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM);
        cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, outer_edit_ptr/2, cmd, &l2edit_out));
        use_spme = 1;
    }
    else
    {
        cmd = DRV_IOR(DsL2Edit6WOuter_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, outer_edit_ptr / 2, cmd, &l2edit_out));
    }

    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
    {
        l2_rewrite_type = GetDsL2Edit6WOuter(V, l2RewriteType_f, &l2edit_out);
        if ((l2_rewrite_type == SYS_NH_L2EDIT_TYPE_ETH_8W) || (l2_rewrite_type == SYS_NH_L2EDIT_TYPE_FLEX_8W) ||
            (l2_rewrite_type == SYS_NH_L2EDIT_TYPE_MAC_SWAP))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", "DsL2Edit6WOuter", outer_edit_ptr / 2,  "6w");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", "DsL2Edit3WOuter", outer_edit_ptr,  "3w");
        }
    }
    else
    {
        l2_rewrite_type = GetDsL2Edit6WOuter(V, l2EditType_f, &l2edit_out);
        if ((l2_rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_ADDETH2X)) || (l2_rewrite_type == DRV_ENUM(DRV_L2EDITTYPE_RWETH2X)))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", use_spme?"DsL3Edit6W3rd":"DsL2Edit6WOuter", outer_edit_ptr / 2,  "6w");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", use_spme?"DsL3Edit6W3rd":"DsL2Edit3WOuter", outer_edit_ptr,  "3w");
        }
    }
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_table_offset(uint8 lchip, uint32 nhid, uint8 bind_type)
{
    sys_nh_info_com_t* p_nhinfo = NULL;
    int32 ret = 0;
    uint32 dsnh_offset = 0;
    uint8 is_dsnh8w = 0;
    uint8 is_rsv_dsnh = 0;
    uint8 loop = 0;
    uint8 loop_cnt = 0;
    uint8 loop2 = 0;
    uint8 loop2_cnt = 0;
    uint32 cmd ;
    DsNextHop4W_m   dsnh4w;
    DsNextHop8W_m   dsnh8w;
    uint32 outer_edit_ptr = 0;
    uint32 inner_edit_ptr = 0;
    uint32 inner_edit_ptr_type = 0 ;
    uint32 outer_edit_ptr_type = 0 ;
    uint32 outer_edit_location = 0 ;
    uint8 share_type = 0;
    ds0_t   l3edit;
    uint8 dsnh_aps_en = 0;
    uint16 aps_bridge_id = 0;
    uint32 next_ptr_valid = 0;
    uint32 spme_en = 0;
    uint32 tmp = 0;
    sys_nh_info_mcast_t *p_mcast_db = NULL;
    uint32 payload_op = 0;
    uint8 is_srv6 = 0;
    uint8 use_spme = 0;
    char str[32];
    uint8 srv6_ldp_en = 0;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_MCAST == p_nhinfo->hdr.nh_entry_type)
    {
        p_mcast_db = (sys_nh_info_mcast_t *)p_nhinfo;
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------\n");

    if (SYS_NH_TYPE_ECMP == p_nhinfo->hdr.nh_entry_type)
    {
        sys_nh_info_ecmp_t *p_ecmp_db = (sys_nh_info_ecmp_t *)p_nhinfo;
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "DsEcmpGroup", p_ecmp_db->ecmp_group_id);
        if (p_ecmp_db->valid_cnt)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "DsEcmpMember", p_ecmp_db->ecmp_member_base/4);
        }
        if (CTC_NH_ECMP_TYPE_XERSPAN == p_ecmp_db->type)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "DsNexthop8w", p_ecmp_db->hdr.dsnh_offset);
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");
        }

        return CTC_E_NONE;
    }

    if (!CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_DSFWD)
        && !CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_RSV_DSFWD))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%s\n", "DsFwd", SYS_NH_DEBUG_NH_MERGE_MODE);
    }
    else
    {
        share_type = CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_DSFWD_IS_6W)?1:0;
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u %s\n", share_type?"DsFwd":"DsFwdHalf", p_nhinfo->hdr.dsfwd_offset, share_type?"[6w]":"[3w]");
    }

    /*Get dsfwd cb information*/
    if ((bind_type == SYS_NH_TYPE_IPUC) ||  (bind_type == SYS_NH_TYPE_MPLS) || \
        (bind_type == SYS_NH_TYPE_IP_TUNNEL) ||  (bind_type == SYS_NH_TYPE_TRILL) ||
        (bind_type == SYS_NH_TYPE_MISC) || (bind_type == SYS_NH_TYPE_SRV6)
        || (bind_type == SYS_NH_TYPE_OVERLAY) || (bind_type == SYS_NH_TYPE_APS))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  --%-19s :%s\n", "Bind", "Yes");
    }

    if (DRV_FROM_AT(lchip))
    {
        if (!CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_DSFWD1)
            && !CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_RSV_DSFWD))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%s\n", "DsFwd1", SYS_NH_DEBUG_NH_MERGE_MODE);
        }
        else
        {
            share_type = CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_DSFWD_IS_6W)? 1 : 0;
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u %s\n", share_type? "DsFwd1" : "DsFwdHalf1", p_nhinfo->hdr.dsfwd1_offset, share_type? "[6w]":"[3w]");
        }
    }

    if (DRV_FROM_AT(lchip) && p_nhinfo->hdr.dsnh_ptr)
    {
        uint32 dsnh_ptr = p_nhinfo->hdr.dsnh_ptr - g_usw_nh_master[lchip]->nh_mapper_base;
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s:%u[%u](%u) \n", "DsNextHopIdMapPointer",
                       (dsnh_ptr & ((g_usw_nh_master[lchip]->nh_mapper_num << 3) - 1)) >> 3,
                       dsnh_ptr&0x7,
                       p_nhinfo->hdr.dsnh_ptr);
    }

    loop = 0;
    loop_cnt = 1;
    if (  CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_EN)
        && !CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_SHARE_DSNH))
    {
        loop_cnt = 2;
    }

    dsnh_offset = p_nhinfo->hdr.dsnh_offset;
    dsnh_offset &= 0x1FFFF;
    is_dsnh8w = CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_USE_DSNH8W);
    if (((dsnh_offset >> SYS_NH_DSNH_INTERNAL_SHIFT) == SYS_NH_DSNH_INTERNAL_BASE) && (SYS_NH_TYPE_APS != p_nhinfo->hdr.nh_entry_type))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "EpeNextHopInternal", (dsnh_offset & 0xF)/2);
        is_rsv_dsnh = 1;
        loop_cnt = 0;
    }

    if (SYS_NH_TYPE_MCAST == p_nhinfo->hdr.nh_entry_type)
    {
        loop_cnt = 0;
        p_mcast_db = (sys_nh_info_mcast_t *)p_nhinfo;
        if (DRV_FROM_AT(lchip))
        {
            uint32 metEntryType = 0;
            ds0_t ds;
            if (g_usw_nh_master[lchip]->met_ext_mode)
            {
                char* met_str[] = {"DsMetEntrySlim1X", "DsMetEntryFit1X", "DsMetEntryFit2X", "Rsv", "DsMetVectorSlim1X", "DsMetVectorSlim2X", "DsMetVectorSlim4X", "Rsv"};
                cmd = DRV_IOR(DsMetEntrySlim1X_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, p_mcast_db->basic_met_offset, cmd, &ds));
                metEntryType = GetDsMetEntrySlim1X(V, metEntryType_f,  &ds);
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [1X]\n", met_str[metEntryType], p_mcast_db->basic_met_offset);
            }
            else
            {
                char* met_str[] = {"DsMetEntry1X", "DsMetVector1X", "DsMetVector2X", "DsMetVector4X"};
                cmd = DRV_IOR(DsMetEntry1X_t, DsMetEntry1X_metEntryType_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, p_mcast_db->basic_met_offset, cmd, &ds));
                metEntryType = GetDsMetEntry1X(V, metEntryType_f,  &ds);
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", met_str[metEntryType], p_mcast_db->basic_met_offset,
                    CTC_FLAG_ISSET(p_mcast_db->mcast_flag, SYS_NH_INFO_MCAST_FLAG_4X_GRP_ID)?"4X":(CTC_FLAG_ISSET(p_mcast_db->mcast_flag, SYS_NH_INFO_MCAST_FLAG_2X_GRP_ID)?"2X":"1X"));
            }
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", (CTC_FLAG_ISSET(p_mcast_db->mcast_flag, SYS_NH_INFO_MCAST_FLAG_2X_GRP_ID))?"DsMetEntry6w":"DsMetEntry3w", p_mcast_db->basic_met_offset,
                    (CTC_FLAG_ISSET(p_mcast_db->mcast_flag, SYS_NH_INFO_MCAST_FLAG_2X_GRP_ID)?"6w":"3w"));
        }
    }

    if (p_nhinfo->hdr.dsnh_offset == SYS_USW_DROP_NH_OFFSET && SYS_NH_TYPE_APS != p_nhinfo->hdr.nh_entry_type)
    {
        loop_cnt = 0;
    }

    if (SYS_NH_TYPE_ILOOP == p_nhinfo->hdr.nh_entry_type||
        SYS_NH_TYPE_DROP == p_nhinfo->hdr.nh_entry_type||
        SYS_NH_TYPE_TOCPU == p_nhinfo->hdr.nh_entry_type)
    {
        return CTC_E_NONE;
    }


    while ((loop++) < loop_cnt)
    {
        sys_nh_info_aps_t* p_aps_nh = (sys_nh_info_aps_t*)p_nhinfo;
        sys_nh_info_com_t* p_tmp = p_nhinfo;
        inner_edit_ptr = 0;
        outer_edit_ptr = 0;
        dsnh_aps_en  = 0;
        outer_edit_ptr = 0;
        inner_edit_ptr = 0;
        inner_edit_ptr_type = 0;
        outer_edit_ptr_type = 0;
        outer_edit_location = 0;

        if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_EN))
        {
            if (loop == 1)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n ---------------------- :%s\n","W [W/P]");
                if (SYS_NH_TYPE_APS == p_nhinfo->hdr.nh_entry_type)
                {
                    CTC_ERROR_RETURN(sys_usw_nh_get_nhinfo_by_nhid(lchip, p_aps_nh->w_nexthop_id,  &p_tmp));
                    dsnh_offset = p_tmp->hdr.dsnh_offset;
                    is_dsnh8w = CTC_FLAG_ISSET(p_tmp->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_USE_DSNH8W);
                }
            }
            else
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n ---------------------- :%s\n","P [W/P]");
                if (SYS_NH_TYPE_APS == p_nhinfo->hdr.nh_entry_type)
                {
                    CTC_ERROR_RETURN(sys_usw_nh_get_nhinfo_by_nhid(lchip, p_aps_nh->p_nexthop_id,  &p_tmp));
                    dsnh_offset = p_tmp->hdr.dsnh_offset;
                    is_dsnh8w = CTC_FLAG_ISSET(p_tmp->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_USE_DSNH8W);
                }
                else
                {
                    dsnh_offset = is_dsnh8w ? (dsnh_offset + 2) : (dsnh_offset + 1);
                }
            }

        }

        if(SYS_NH_TYPE_SRV6 == p_tmp->hdr.nh_entry_type)
        {
            sys_nh_info_srv6_t* p_nh_srv6_info = (sys_nh_info_srv6_t*)(p_tmp);
            sys_nh_db_srh_t    *p_srh_tnl = NULL;
            p_srh_tnl = _sys_usw_nh_lkup_srh_id(lchip, p_nh_srv6_info->srh_id);
            is_srv6 = ((p_srh_tnl && (p_srh_tnl->num || CTC_FLAG_ISSET(p_srh_tnl->flag, SYS_NH_SRH_FLAG_APS))) || (0 != p_nh_srv6_info->ecmp_if_id))? 1 : 0;
            srv6_ldp_en = CTC_FLAG_ISSET(p_nh_srv6_info->flag, SYS_NH_SRV6_FLAG_SRH_IS_LDP);
        }


        if ((dsnh_offset >> SYS_NH_DSNH_INTERNAL_SHIFT) == SYS_NH_DSNH_INTERNAL_BASE)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "EpeNextHopInternal", (dsnh_offset & 0xF)/2);
        }
        else
        {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", (is_dsnh8w ? "DsNexthop8w" : "DsNexthop4w"), dsnh_offset, (is_dsnh8w ? "8w" : "4w"));
        }

        if (CTC_FLAG_ISSET(p_tmp->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
        {
            continue;
        }

        if ((DRV_IS_TMM(lchip) || DRV_IS_TMG(lchip)) && is_srv6 && (2 == loop_cnt))/*srv6 aps*/
        {
            continue;
        }

        if (is_dsnh8w && !is_rsv_dsnh )
        {
            cmd = DRV_IOR(DsNextHop8W_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, dsnh_offset, cmd, &dsnh8w));

            share_type = GetDsNextHop8W(V, shareType_f,  &dsnh8w);
            outer_edit_location =  GetDsNextHop8W(V, outerEditLocation_f, &dsnh8w);
            outer_edit_ptr_type = GetDsNextHop8W(V, outerEditPtrType_f, &dsnh8w);
            outer_edit_ptr =  GetDsNextHop8W(V, outerEditPtr_f, &dsnh8w);
            inner_edit_ptr_type = GetDsNextHop8W(V, innerEditPtrType_f, &dsnh8w);
            inner_edit_ptr =  GetDsNextHop8W(V, innerEditPtr_f, &dsnh8w);
            dsnh_aps_en = GetDsNextHop8W(V, apsBridgeEn_f, &dsnh8w);
        }
        else if(!is_dsnh8w && !is_rsv_dsnh)
        {
            cmd = DRV_IOR(DsNextHop4W_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, dsnh_offset, cmd, &dsnh4w));
            dsnh_aps_en = GetDsNextHop4W(V, apsBridgeEn_f, &dsnh4w);
            share_type = GetDsNextHop4W(V, shareType_f,  &dsnh4w);

            payload_op = GetDsNextHop4W(V, payloadOperation_f,  &dsnh4w);
            if (SYS_NH_OP_ROUTE_COMPACT == payload_op)
            {
                continue;
            }
            else if (share_type == SYS_NH_SHARE_TYPE_L23EDIT)
            {
                outer_edit_location =  GetDsNextHop4W(V, outerEditLocation_f, &dsnh4w);
                outer_edit_ptr_type = GetDsNextHop4W(V, outerEditPtrType_f, &dsnh4w);
                outer_edit_ptr =  GetDsNextHop4W(V, outerEditPtr_f, &dsnh4w);
                inner_edit_ptr_type = GetDsNextHop4W(V, innerEditPtrType_f,  &dsnh4w);
                inner_edit_ptr =  GetDsNextHop4W(V, innerEditPtr_f, &dsnh4w);
            }
            else if ((share_type == SYS_NH_SHARE_TYPE_L2EDIT_VLAN) && (GetDsNextHop4W(V, outerEditPtrValid_f, &dsnh4w)))
            {
                if (GetDsNextHop4W(V, outerEditPtrAsInner_f, &dsnh4w))
                {
                    inner_edit_ptr_type = GetDsNextHop4W(V, u1_g4_outerEditPtrType_f, &dsnh4w);
                    inner_edit_ptr =  GetDsNextHop4W(V, u1_g4_outerEditPtr_f, &dsnh4w);
                    outer_edit_ptr = 0;
                }
                else
                {
                    outer_edit_location =  GetDsNextHop4W(V, u1_g4_outerEditLocation_f, &dsnh4w);
                    outer_edit_ptr_type = GetDsNextHop4W(V, u1_g4_outerEditPtrType_f, &dsnh4w);
                    outer_edit_ptr =  GetDsNextHop4W(V, u1_g4_outerEditPtr_f, &dsnh4w);
                    inner_edit_ptr = 0;
                }
            }
        }


        if (DRV_FROM_TMM(lchip) && (is_srv6) && ((0 != inner_edit_ptr) || dsnh_aps_en || (1 == srv6_ldp_en)))
        {
            tmp = outer_edit_ptr;
            outer_edit_ptr = inner_edit_ptr;
            inner_edit_ptr = tmp;

            tmp = outer_edit_ptr_type;
            outer_edit_ptr_type = inner_edit_ptr_type;
            inner_edit_ptr_type =  tmp;
        }
        /*
        inner_edit:ptr_type
        0- L2Edit
        1- L3Edit

        outer_edit: location / type
        0 / 1   L3Edit (Pipe0) -- > ( L3Edit (Pipe1), opt)-- > L2Edit(Pipe2)
        0 / 0   L2Edit (Pipe0) -- > L3Edit(Pipe1)
        1 / 0   L2Edit (Pipe2)
        1 / 1   L3Edit (Pipe1) -- > L2Edit(Pipe2)
        */
        if (inner_edit_ptr != 0)
        {
            if (inner_edit_ptr_type)
            {
                sal_sprintf(str, "%s", _sys_usw_nh_dump_get_l3rewrite_desc(lchip, inner_edit_ptr, (is_srv6 && DRV_FROM_AT(lchip)) ? 0 : 1));
                if (!is_srv6 && DRV_FROM_AT(lchip))
                {
                    sal_strcat(str, "0");
                }
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u\n",
                    (is_srv6 && (DRV_IS_TMM(lchip) || DRV_IS_TMG(lchip))) ? "DsL3EditAddIp6ExtHeader" : str, inner_edit_ptr );
            }
            else
            {
                sal_sprintf(str, "%s", _sys_usw_nh_dump_get_l2rewrite_desc(lchip, inner_edit_ptr, 1));
                if (DRV_FROM_AT(lchip))
                {
                    sal_strcat(str, "0");
                }
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u\n", str, inner_edit_ptr );
            }
        }

        loop2 = 0;
        loop2_cnt = dsnh_aps_en?2:1;
        aps_bridge_id = outer_edit_ptr;

        while ((loop2++) < loop2_cnt)
        {
            if (dsnh_aps_en)
            {
                if (DRV_FROM_AT(lchip))
                {
                    DsEpeApsBridge_m ds_apsbrdige;
                    cmd = DRV_IOR(DsEpeApsBridge_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, aps_bridge_id, cmd, &ds_apsbrdige));
                    if (loop2 == 1)
                    {
                        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n -W [W/P]\n");
                        outer_edit_ptr = GetDsEpeApsBridge(V, workingOuterEditPtr_f, &ds_apsbrdige);
                        outer_edit_ptr_type = GetDsEpeApsBridge(V, workingOuterEditPtrType_f, &ds_apsbrdige);
                        outer_edit_location = GetDsEpeApsBridge(V, workingOuterEditLocation_f, &ds_apsbrdige);
                    }
                    else
                    {
                        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n -P [W/P]\n");
                        outer_edit_ptr = GetDsEpeApsBridge(V, protectingOuterEditPtr_f, &ds_apsbrdige);
                        outer_edit_ptr_type = GetDsEpeApsBridge(V, protectingOuterEditPtrType_f, &ds_apsbrdige);
                        outer_edit_location = GetDsEpeApsBridge(V, protectingOuterEditLocation_f, &ds_apsbrdige);
                    }
                    spme_en = GetDsEpeApsBridge(V, spmeApsEn_f, &ds_apsbrdige);

                }
                else
                {
                    DsApsBridge_m ds_apsbrdige;
                    cmd = DRV_IOR(DsApsBridge_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, aps_bridge_id, cmd, &ds_apsbrdige));
                    if (loop2 == 1)
                    {
                        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n -W [W/P]\n");
                        outer_edit_ptr = GetDsApsBridge(V, workingOuterEditPtr_f, &ds_apsbrdige);
                        outer_edit_ptr_type = GetDsApsBridge(V, workingOuterEditPtrType_f, &ds_apsbrdige);
                        outer_edit_location = GetDsApsBridge(V, workingOuterEditLocation_f, &ds_apsbrdige);
                    }
                    else
                    {
                        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n -P [W/P]\n");
                        outer_edit_ptr = GetDsApsBridge(V, protectingOuterEditPtr_f, &ds_apsbrdige);
                        outer_edit_ptr_type = GetDsApsBridge(V, protectingOuterEditPtrType_f, &ds_apsbrdige);
                        outer_edit_location = GetDsApsBridge(V, protectingOuterEditLocation_f, &ds_apsbrdige);
                    }
                    spme_en = GetDsApsBridge(V, spmeApsEn_f, &ds_apsbrdige);
                }
            }

            if (outer_edit_location && outer_edit_ptr_type && g_usw_nh_master[lchip]->mpls_spme_dis)
            {
                use_spme = 1;
                outer_edit_ptr &= (DRV_FROM_TMM(lchip)?(~(1 << 11)):~((1 << 10)));
            }

            next_ptr_valid =  outer_edit_location&&!outer_edit_ptr_type ? 1: 0;

            if (outer_edit_ptr != 0)
            {
                if (1 == outer_edit_ptr_type && 0 == outer_edit_location)
                {   /*L3 Edit*/
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u\n",
                                (is_srv6 && DRV_FROM_AT(lchip)) ?
                                "DsL3EditAddIp6ExtHeader" :
                                _sys_usw_nh_dump_get_l3rewrite_desc(lchip, outer_edit_ptr, (is_srv6 && DRV_FROM_AT(lchip)) ? 1 : 0),
                                outer_edit_ptr );
                    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
                    {
                        cmd = DRV_IOR(DsL3EditMpls3W_t, DRV_ENTRY_FLAG);
                    }
                    else if (is_srv6 && DRV_FROM_AT(lchip))
                    {
                        cmd = DRV_IOR(DsL3EditAddMpls1X0_t, DRV_ENTRY_FLAG);
                    }
                    else
                    {
                        cmd = DRV_IOR(DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
                    }
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, outer_edit_ptr, cmd, &l3edit));
                    if (DRV_FROM_TMM(lchip))
                    {
                        outer_edit_ptr_type =  GetDsL3EditAddMpls1X(V, outerEditPtrType_f, &l3edit);
                        outer_edit_ptr =  GetDsL3EditAddMpls1X(V, outerEditPtr_f, &l3edit);
                        next_ptr_valid = GetDsL3EditAddMpls1X(V, nextEditPtrValid_f, &l3edit);
                    }
                    else
                    {
                        outer_edit_ptr_type =  GetDsL3EditMpls3W(V, outerEditPtrType_f, &l3edit);
                        outer_edit_ptr =  GetDsL3EditMpls3W(V, outerEditPtr_f, &l3edit);
                        next_ptr_valid = GetDsL3EditMpls3W(V, nextEditPtrValid_f, &l3edit);
                    }

                    use_spme |= (!next_ptr_valid && g_usw_nh_master[lchip]->mpls_spme_dis);
                }
                else if(0 == outer_edit_ptr_type && 0 == outer_edit_location)
                {   /*L2 Edit*/
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u\n", _sys_usw_nh_dump_get_l2rewrite_desc(lchip, outer_edit_ptr, 0), outer_edit_ptr );
                }

                /*SPME*/
                if (next_ptr_valid && 1 == outer_edit_ptr_type && !g_usw_nh_master[lchip]->mpls_spme_dis)
                {
                    DsL3Edit6W3rd_m l3edit6w;

                    outer_edit_ptr = spme_en?(outer_edit_ptr + 1):outer_edit_ptr;
                    cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, outer_edit_ptr/2, cmd, &l3edit6w));
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u\n", "DsL3Edit6W3rd", outer_edit_ptr/2);

                    if (outer_edit_ptr % 2 == 0)
                    {
                        sal_memcpy(&l3edit, (uint8*)&l3edit6w,  DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W3rd_t)/2);
                    }
                    else
                    {
                        sal_memcpy( &l3edit, (uint8*)&l3edit6w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W3rd_t)/2, DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W3rd_t)/2);
                    }

                    outer_edit_ptr_type =  GetDsL3Edit3W3rd(V, outerEditPtrType_f, &l3edit);
                    outer_edit_ptr =  GetDsL3Edit3W3rd(V, outerEditPtr_f, &l3edit);
                    next_ptr_valid = GetDsL3Edit3W3rd(V, nextEditPtrValid_f, &l3edit);
                }

                /*OUT Edit*/
                if ((next_ptr_valid && 0 == outer_edit_ptr_type) || use_spme)
                {
                    /*L2 Edit outer*/
                    outer_edit_ptr += use_spme?MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM):0;
                    _sys_usw_nh_dump_l2edit_outer(lchip, outer_edit_ptr);
                }


            }
        }
    }

    if (SYS_NH_TYPE_IPUC == p_nhinfo->hdr.nh_entry_type)
    {
        sys_nh_info_ipuc_t *p_ipuc_db = NULL;
        p_ipuc_db = (sys_nh_info_ipuc_t *)p_nhinfo;
        if (p_ipuc_db->ldp_ext)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "DsEgressLogicDestPort", p_ipuc_db->ldp_ext);
        }
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_brguc(uint8 lchip, uint32 nhid, uint8 detail)
{
    sys_nh_info_brguc_t* p_brguc_info = NULL;
    sys_nh_info_com_t* p_nhinfo = NULL;
	ctc_aps_bridge_group_t  aps_group ;
    int32 ret;

     char* sub_type[] = {"None", "Basic", "Bypass", "VLAN edit", "APS VLAN edit"};
     char nh_str[50] = {0};

     ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_BRGUC != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't BridgeUC nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_brguc_info = (sys_nh_info_brguc_t*)(p_nhinfo);

    CTC_MAX_VALUE_CHECK(p_brguc_info->nh_sub_type, (SYS_NH_PARAM_BRGUC_SUB_TYPE_MAX - 1));
    NHID_CONVERT_STR(nhid, nh_str);

    if (CTC_FLAG_ISSET(p_brguc_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_APS_EN))
    {
        sys_usw_aps_get_ports(lchip, p_brguc_info->dest_gport, &aps_group);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s%-17s%-16s 0x%.4x%6s %s\n",nh_str,
                "Bridge Unicast", sub_type[p_brguc_info->nh_sub_type], aps_group.working_gport, "", aps_group.protect_en?"N":"Y");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s%-17s%-16s 0x%.4x%6s %s\n", "", "", "",
                       aps_group.protection_gport, "", aps_group.protect_en?"Y":"N");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s%-17s%-16s 0x%.4x%6s %s\n", nh_str,
                "Bridge Unicast", sub_type[p_brguc_info->nh_sub_type], p_brguc_info->dest_gport, "", "Y");
	}

    if (p_brguc_info->nh_sub_type == SYS_NH_PARAM_BRGUC_SUB_TYPE_VLAN_EDIT)
    {
        sys_usw_nh_dump_xvlan(lchip, nhid, detail);
    }

    return CTC_E_NONE;
}

STATIC int32
sys_usw_nh_dump_ipuc_brief(uint8 lchip, uint32 nhid, sys_nh_info_ipuc_t* p_ipuc_info)
{
    ctc_ip_nh_param_t ipuc_param;
    sys_l3if_prop_t l3if_prop;
    int32 ret = CTC_E_NONE;
    sys_nh_db_arp_t *p_arp = NULL;
    char nh_str[50] = {0};

    sal_memset(&l3if_prop, 0, sizeof(sys_l3if_prop_t));

    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "IP Unicast");

    sal_memset(&ipuc_param, 0, sizeof(ipuc_param));
    CTC_ERROR_RETURN(sys_usw_nh_get_ipuc_cb(lchip,(sys_nh_info_com_t*)p_ipuc_info, &ipuc_param));
    if (p_ipuc_info->arp_id)
    {
       p_arp = (sys_usw_nh_lkup_arp_id(lchip, p_ipuc_info->arp_id));
       if (NULL == p_arp)
       {
           return CTC_E_NOT_EXIST;
       }
    }

    if (CTC_FLAG_ISSET(p_ipuc_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%-9s%-10s%-16s%-8s\n", "-", "-", "-", "-", "-");
        return CTC_E_NONE;
    }

    if (CTC_IS_CPU_PORT(p_ipuc_info->gport) || (p_arp && CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_REDIRECT_TO_CPU)))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%s          ", "CPU");
    }
    else if (p_arp && CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_DROP))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%s          ", "Drop");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%04X       ", p_ipuc_info->gport);
    }

    l3if_prop.l3if_id = p_ipuc_info->l3ifid;
    ret = sys_usw_l3if_get_l3if_info(lchip, 1, &l3if_prop);
    if (CTC_E_NONE != ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10s", "-");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9s",  "-");
    }
    else
    {
        if (CTC_L3IF_TYPE_PHY_IF == l3if_prop.l3if_type)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9s", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9u", l3if_prop.vlan_id);
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10u", l3if_prop.l3if_id);
    }

    if(p_ipuc_info->arp_id)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-16d", p_ipuc_info->arp_id);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-16s", sys_output_mac(ipuc_param.mac));
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s\n", "Y");

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_ipuc(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_ipuc_t* p_ipuc_info = NULL;
    sys_nh_info_com_t* p_nh_com_info = NULL;
    sys_nh_info_dsnh_t nh_dsnh_info;
    int32 ret = CTC_E_NONE;

    ret = sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid, &p_nh_com_info);

    sal_memset(&nh_dsnh_info, 0, sizeof(sys_nh_info_dsnh_t));
    ret = (ret < 0) ? ret : _sys_usw_nh_get_nhinfo(lchip, nhid, &nh_dsnh_info);

    if (ret  !=CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_IPUC != p_nh_com_info->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't IPUC nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_ipuc_info = (sys_nh_info_ipuc_t*)(p_nh_com_info);
    if (p_ipuc_info->pd->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_IPUC;
    }

    CTC_ERROR_RETURN(sys_usw_nh_dump_ipuc_brief(lchip, nhid, p_ipuc_info));

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_ecmp(uint8 lchip, uint32 nhid, uint8 detail)
{
    sys_nh_info_ecmp_t* p_ecmp_info = NULL;
    sys_nh_info_com_t* p_nhinfo = NULL;
    int32 ret;
    uint16 loop = 0;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret  !=CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_ECMP != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't ECMP nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }


    p_ecmp_info = (sys_nh_info_ecmp_t*)(p_nhinfo);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8uECMP\n", nhid);

    if (detail)
    {
       SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n--%-18s: %u \n","Max member num ", p_ecmp_info->mem_num );
       SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "--%-18s: %u \n","Valid member num", p_ecmp_info->valid_cnt );
       if (p_ecmp_info->rpf_en)
       {
           SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "--%-18s: %u \n","rpf profile id", p_ecmp_info->rpf_id );
       }
       if (p_ecmp_info->mem_is_tunnel)
       {
           SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "--%-18s\n","member is srh");
       }
       SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,"---------------------------\n");

       SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-6s%16s\n", "No.", "MEMBER_NHID");
       SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,"---------------------------\n");
       for (loop = 0; loop < p_ecmp_info->ecmp_cnt; loop++)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6d%16u\n", loop, p_ecmp_info->nh_array[loop]);
        }
    }

    return CTC_E_NONE;
}


int32
sys_usw_nh_dump_aps(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_aps_t* p_aps_info = NULL;
    sys_nh_info_com_t* p_nhinfo = NULL;
    int32 ret;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret  !=CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_APS != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't APS nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }


    p_aps_info = (sys_nh_info_aps_t*)(p_nhinfo);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,"%-8uAPS\n", nhid);

    if (detail)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,"\n%-12s%-6s\n","MEMBER_NHID", "W/P");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,"-------------------\n");

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12u%-6s\n", p_aps_info->w_nexthop_id, "W");
        if (p_aps_info->p_nexthop_id)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12u%-6s\n", p_aps_info->p_nexthop_id, "P");
        }
    }

    if (p_aps_info->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_APS;
    }
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_ip_mcast_l3if_info(uint8 lchip, uint32 gport, uint16 vlan_id, uint16 cvlan_id)
{
    int32 ret = CTC_E_NONE;
    sys_l3if_prop_t l3if_prop;

    sal_memset(&l3if_prop,0,sizeof(sys_l3if_prop_t));
    ret = sys_usw_l3if_get_l3if_info_with_port_and_vlan(lchip, gport, vlan_id, cvlan_id, &l3if_prop);
    if (CTC_E_NONE == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9u%-8u%s\n", l3if_prop.vlan_id, l3if_prop.l3if_id, "-");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9s%-8s%s\n", "-", "-", "-");
    }
    return CTC_E_NONE;
}

void
sys_usw_nh_dump_mcast_member_info(uint8 lchip, sys_nh_mcast_meminfo_t* p_meminfo_com, uint32* p_memcnt, uint32 gport,uint8 aps_en)
{
    uint16  loop = 0;
    if ((SYS_NH_PARAM_BRGMC_MEM_LOCAL == p_meminfo_com->dsmet.member_type)
        ||(SYS_NH_PARAM_BRGMC_MEM_BITMAP == p_meminfo_com->dsmet.member_type)
       || (SYS_NH_PARAM_BRGMC_MEM_RAPS == p_meminfo_com->dsmet.member_type))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", *p_memcnt);

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s0x%.4x%-4s%-9s%-8s%s\n", "L2 Mcast",gport,"", "-", "-", "-");
    }

    else if(SYS_NH_PARAM_BRGMC_MEM_LOCAL_WITH_APS_BRIDGE == p_meminfo_com->dsmet.member_type)
    {

        gport = p_meminfo_com->dsmet.ucastid;
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", *p_memcnt);

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s0x%.4x%-4s%-9s%-8s%u\n", "L2 Mcast", gport, "", "APS", "-", p_meminfo_com->dsmet.ref_nhid);
    }
    else if (SYS_NH_PARAM_MCAST_MEM_LOCAL_LOGIC_REP == p_meminfo_com->dsmet.member_type)
    {
        for (loop = 0; loop <= p_meminfo_com->dsmet.replicate_num ; loop ++)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6d", (*p_memcnt)++);
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14s", "L2 Mcast");
            if (p_meminfo_com->dsmet.replicate_num == 0)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%-9s%-8s%u\n", "-", "-", "-", p_meminfo_com->dsmet.ref_nhid);
            }
            else
            {
                if (CTC_FLAG_ISSET(p_meminfo_com->dsmet.flag, SYS_NH_DSMET_FLAG_USE_DSNH8W))
                {
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%-9s%-8s%d\n", "-", "-", "-", p_meminfo_com->dsmet.vid_list[loop*2]);
                }
                else
                {
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%-9s%-8s%d\n", "-", "-", "-", p_meminfo_com->dsmet.vid_list[loop]);
                }
            }
        }
    }
    else if (SYS_NH_PARAM_IPMC_MEM_LOCAL_LOGIC_REP == p_meminfo_com->dsmet.member_type)
    {
        for (loop = 0; loop < (p_meminfo_com->dsmet.replicate_num + 1); loop++)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", (*p_memcnt)++);
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s0x%.4x%-4s", "IP Mcast", gport, "");
            if (p_meminfo_com->dsmet.vid_list)
            {
                sys_usw_nh_dump_ip_mcast_l3if_info(lchip, gport, p_meminfo_com->dsmet.vid_list[loop], 0);
            }
            else
            {
                sys_usw_nh_dump_ip_mcast_l3if_info(lchip, gport, p_meminfo_com->dsmet.vid, p_meminfo_com->dsmet.cvid);
            }
        }
        /*This parameter has plused extra a number in the final loop,so it should be subtracted one number*/
        (*p_memcnt)--;
    }
    else if (SYS_NH_PARAM_IPMC_MEM_LOCAL == p_meminfo_com->dsmet.member_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", *p_memcnt);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s0x%.4x%-4s", "IP Mcast", gport, "");
        sys_usw_nh_dump_ip_mcast_l3if_info(lchip, gport, p_meminfo_com->dsmet.vid, p_meminfo_com->dsmet.cvid);
    }
    else if (SYS_NH_PARAM_MCAST_MEM_LOCAL_WITH_NH_DESTID == p_meminfo_com->dsmet.member_type
        ||SYS_NH_PARAM_MCAST_MEM_LOCAL_WITH_NH == p_meminfo_com->dsmet.member_type
       || (SYS_NH_PARAM_MCAST_MEM_MIRROR_WITH_NH == p_meminfo_com->dsmet.member_type))
    {
        uint32 cmd = 0;
        uint32 dest_map = 0;
        uint8  arp_cpu = 0;
        sys_nh_info_dsnh_t nh_info;
        sal_memset(&nh_info, 0, sizeof(nh_info));
        _sys_usw_nh_get_nhinfo(lchip, p_meminfo_com->dsmet.ref_nhid, &nh_info);

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", *p_memcnt);
        if (CTC_FLAG_ISSET(p_meminfo_com->dsmet.flag, SYS_NH_DSMET_FLAG_DESTMAP_PROFILE))
        {
            cmd = DRV_IOR(DsDestMapProfileMc_t, DsDestMapProfileMc_destMap_f);
            DRV_FIELD_IOCTL(lchip, (p_meminfo_com->dsmet.ucastid&0x7ff), cmd, &dest_map);
            gport = SYS_USW_DESTMAP_TO_DRV_GPORT(dest_map);
            gport = SYS_MAP_DRV_GPORT_TO_CTC_GPORT(gport);
            arp_cpu = (dest_map == 0xffff)?1:0;
        }
        if(nh_info.logic_rep_list)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s0x%.4x%-4s%-9s%-8s", "Logic Rep", gport, "", "-", "-");
        }
        else if ((sys_usw_chip_is_eth_cpu_port(lchip, p_meminfo_com->dsmet.ucastid)) || arp_cpu)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%s   %-4s%-9s%-8s", "L2 Mcast", "CPU", "", "-", "-");
        }
        else
        {
            if((p_meminfo_com->dsmet.ref_nhid != 2) && (p_meminfo_com->dsmet.ref_nhid != 1))
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s0x%.4x%-4s%-9s%-8s", "L2 Mcast", gport, "", "-", "-");
            }
            else
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%3s   %-4s%-9s%-8s", "L2 Mcast", "-", "", "-", "-");
            }
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%u\n", p_meminfo_com->dsmet.ref_nhid);
    }
    else if(SYS_NH_PARAM_MEM_LOGIC_REP_LIST == p_meminfo_com->dsmet.member_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", *p_memcnt);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%-10d%-14d%-10d\n", "Logic Rep", p_meminfo_com->dsmet.vid, p_meminfo_com->dsmet.ref_nhid, p_meminfo_com->dsmet.dsmet_offset);

    }
}

void
sys_usw_nh_dump_mcast_bitmap_info(uint8 lchip, sys_nh_mcast_meminfo_t* p_meminfo_com, uint8 gchip, uint32* p_memcnt, sys_met_t* p_dsmet)
{
    uint8 loop = 0;
    uint16 gport = 0;
    uint8 i = 0;

    for (i = 0; i < (MCHIP_CAP(SYS_CAP_NH_MC_PBMP_NUM)/32); i++)
    {
        for (loop = 0; ((loop < 32) && p_dsmet->port_bitmap[i]); loop++)
        {
            if (CTC_IS_BIT_SET(p_dsmet->port_bitmap[i], loop))
            {
                if (CTC_FLAG_ISSET(p_meminfo_com->dsmet.flag, SYS_NH_DSMET_FLAG_IS_LINKAGG))
                {
                    gport = CTC_MAP_TID_TO_GPORT(loop + (i*32) +  p_meminfo_com->dsmet.port_type*SYS_NH_MCAST_MEMBER_BITMAP_SIZE);
                }
                else
                {
                    gport = CTC_MAP_LPORT_TO_GPORT(gchip, (loop + (i*32)+ p_meminfo_com->dsmet.port_type*SYS_NH_MCAST_MEMBER_BITMAP_SIZE));
                }
                (*p_memcnt)++;
                sys_usw_nh_dump_mcast_member_info(lchip, p_meminfo_com, p_memcnt, gport, 0);
            }
        }
    }

}

int32
sys_usw_nh_dump_mcast_brief(uint8 lchip, uint32 nhid, sys_nh_info_mcast_t*  p_mcast_info, bool detail)
{
    sys_nh_mcast_meminfo_t* p_meminfo_com;
    ctc_list_pointer_node_t* p_pos;
    uint32 memcnt = 0;
    uint8 gchip = 0;
    uint16 gport = 0;
    uint8 have_mcast_profile = 0;
    char  nh_str[30] = {0};

    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", nh_str);

    if (CTC_FLAG_ISSET(p_mcast_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_MCAST_PROFILE))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "Mcast-Profile");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "Mcast");
    }

    if (CTC_FLAG_ISSET(p_mcast_info->mcast_flag, SYS_NH_INFO_MCAST_FLAG_STK_MEM_PROFILE) ||
        CTC_FLAG_ISSET(p_mcast_info->mcast_flag, SYS_NH_INFO_MCAST_FLAG_MEM_PROFILE))
    {
        have_mcast_profile = 1;
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15u", p_mcast_info->basic_met_offset >> g_usw_nh_master[lchip]->met_mode);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s\n",
                   ((CTC_FLAG_ISSET(p_mcast_info->mcast_flag, SYS_NH_INFO_MCAST_FLAG_LOGIC_REP_EN)
                   | CTC_FLAG_ISSET(p_mcast_info->mcast_flag, SYS_NH_INFO_MCAST_FLAG_LOGIC_REP_LIST_EN)
                   | CTC_FLAG_ISSET(p_mcast_info->mcast_flag, SYS_NH_INFO_MCAST_FLAG_LOGIC_REP_ABILITY))? "Enable" : "Disable"));

if (detail)
{
    if (CTC_FLAG_ISSET(p_mcast_info->mcast_flag, SYS_NH_INFO_MCAST_FLAG_LOGIC_REP_LIST_EN))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nLogic Replication(DsQMsgReplicationList):\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-----------------------------------------------------------\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6s%-13s%-10s%-14s%-10s\n",
                       "No.", "MEMBER_TYPE", "VLAN",  "MEMBER_NHID", "REP_IDX");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nMulticast Member:\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-----------------------------------------------------------\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6s%-13s%-10s%-9s%-8s%s\n",
                       "No.", "MEMBER_TYPE", "DESTPORT", "VLAN", "L3IFID", "MEMBER_NHID");
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-----------------------------------------------------------\n");
    CTC_ERROR_RETURN(sys_usw_get_gchip_id(lchip, &gchip));
    CTC_LIST_POINTER_LOOP(p_pos, &(p_mcast_info->p_mem_list))
    {
           p_meminfo_com = _ctc_container_of(p_pos, sys_nh_mcast_meminfo_t, list_head);
           if ((!p_meminfo_com->dsmet.logic_port || sys_usw_nh_is_xgpon_hybrid(lchip, p_meminfo_com->dsmet.logic_port))
                && CTC_FLAG_ISSET(p_meminfo_com->dsmet.flag, SYS_NH_DSMET_FLAG_USE_PBM))
            {
                sys_met_t dsmet;
                sal_memset(&dsmet, 0, sizeof(dsmet));
                CTC_ERROR_RETURN(sys_usw_nh_read_asic_table(lchip, p_meminfo_com->dsmet.entry_type, p_meminfo_com->dsmet.dsmet_offset, &dsmet));

                if (MCHIP_NH(lchip)->dump_mcast_bitmap_info)
                {
                    MCHIP_NH(lchip)->dump_mcast_bitmap_info(lchip, p_meminfo_com, gchip, &memcnt, &dsmet);
                }
                else
                {
                    sys_usw_nh_dump_mcast_bitmap_info(lchip, p_meminfo_com, gchip, &memcnt, &dsmet);
                }
            }
            else
            {
                memcnt++;
                if (CTC_FLAG_ISSET(p_meminfo_com->dsmet.flag, SYS_NH_DSMET_FLAG_IS_LINKAGG))
                {
                    gport = CTC_MAP_TID_TO_GPORT(p_meminfo_com->dsmet.ucastid);
                }
                else
                {
                    gport = SYS_MAP_DRV_LPORT_TO_CTC_GPORT(gchip, (p_meminfo_com->dsmet.ucastid & 0x1FF));
                }
                sys_usw_nh_dump_mcast_member_info(lchip, p_meminfo_com, &memcnt, gport, 0);
            }

            if (CTC_FLAG_ISSET(p_meminfo_com->dsmet.flag, SYS_NH_DSMET_FLAG_LOGIC_REPLI_EN))
            {
                sys_nh_mcast_meminfo_t* logic_rep_node = NULL;
                ctc_list_pointer_node_t* p_logic_pos = NULL;
                uint16 loop = 0;
                p_logic_pos = ctc_list_pointer_head(&p_meminfo_com->dsmet.logic_rep_list);
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  %-6s%-13s%-20s %s\n",
                       "No.", "MEMBER_TYPE", "DsQMsgReplicationList", "MEMBER_NHID");
                for (loop = 0; loop < p_meminfo_com->dsmet.replicate_num ; loop ++)
                {
                    logic_rep_node = _ctc_container_of(p_logic_pos, sys_nh_mcast_meminfo_t, list_head);
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  %-6d",  loop);
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  %-14s", "Logic rep");
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  %-20u %u\n", logic_rep_node->dsmet.dsmet_offset, logic_rep_node->dsmet.ref_nhid);
                    p_logic_pos = ctc_list_pointer_next(p_logic_pos);
                }
            }
      }

    if (have_mcast_profile)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-6u", (memcnt+1));
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s%-10u%-9s%-8s%s\n", "Profile",p_mcast_info->profile_nh_id, "-", "-", "-");
    }
}
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_mcast(uint8 lchip, uint32 nhid, bool detail)
{
    sys_nh_info_mcast_t* p_mcast_info = NULL;

    sys_nh_info_com_t* p_nhinfo = NULL;
    int32 ret;

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_FUNC, "%s()\n", __FUNCTION__);

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret  !=CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_MCAST != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't BridgeMC nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_mcast_info = (sys_nh_info_mcast_t*)(p_nhinfo);

    CTC_ERROR_RETURN(sys_usw_nh_dump_mcast_brief(lchip, nhid, p_mcast_info, detail));
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_mpls(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_mpls_t* p_mpls_info;
    sys_nh_info_com_t* p_nhinfo = NULL;
    int32  ret;
    uint32 cmd = 0;
    uint32 vc_label = 0;
    char   vc_label_str[10] = {0};
    char   aps_group_str[10] = {0};
    ds0_t  dsl3edit;
    sys_l3if_prop_t l3if_prop;
    sys_nh_db_arp_t* p_arp =NULL;
    char nh_str[50] = {0};

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (ret  !=CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_MPLS != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't MPLS nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_mpls_info = (sys_nh_info_mpls_t*)(p_nhinfo);

    if (p_mpls_info->pd->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_MPLS;
    }

    if (p_mpls_info->arp_id)
    {
       p_arp = (sys_usw_nh_lkup_arp_id(lchip, p_mpls_info->arp_id));
       if (NULL == p_arp)
       {
           return CTC_E_NOT_EXIST;
       }
    }

    NHID_CONVERT_STR(nhid, nh_str);

    sal_sprintf(aps_group_str, "%s", "-");
    sal_sprintf(vc_label_str, "%s", "-");


    /*MPLS POP Nexthop*/
    if (CTC_FLAG_ISSET(p_mpls_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_MPLS_POP_NH))
    {

        if (CTC_IS_CPU_PORT(p_mpls_info->gport) || (p_arp && CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_REDIRECT_TO_CPU)))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s%-15s%4s%7s", nh_str, "MPLS-POP", "CPU", "");
        }
        else if (p_arp && CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_DROP))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s%-15s%4s%7s", nh_str, "MPLS-POP", "Drop", "");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s%-15s0x%.4x%7s", nh_str, "MPLS-POP", p_mpls_info->gport, "");
        }

        l3if_prop.l3if_id = p_mpls_info->l3ifid;
        ret = sys_usw_l3if_get_l3if_info(lchip, 1, &l3if_prop);
        if (CTC_E_NONE != ret)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9s%-10s", "-", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9u%-10u", l3if_prop.vlan_id, l3if_prop.l3if_id);
        }

        if(p_mpls_info->arp_id)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%d\n", p_mpls_info->arp_id);
        }
        else
        {
            sys_dsl2edit_eth_t   dsl2edit;
            sal_memset(&dsl2edit, 0, sizeof(dsl2edit));
            CTC_ERROR_RETURN(sys_usw_nh_read_asic_table(lchip, SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_4W, p_mpls_info->outer_l2_ptr, &dsl2edit));
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%s\n", sys_output_mac(dsl2edit.mac_da));
        }


         return CTC_E_NONE;
     }

    /*MPLS PUSH Nexthop*/
    if (CTC_FLAG_ISSET(p_mpls_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_L3EDIT))
    {
        if (DRV_FROM_TMM(lchip))
        {
            cmd = DRV_IOR(DRV_FROM_AT(lchip)?DsL3EditAddMpls1X0_t : DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
        }
        else
        {
            cmd = DRV_IOR(DsL3EditMpls3W_t, DRV_ENTRY_FLAG);
        }
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, p_mpls_info->dsl3edit_offset, cmd, &dsl3edit));
        if (DRV_FROM_TMM(lchip))
        {
            vc_label = GetDsL3EditAddMpls1X(V, label_f, &dsl3edit);
        }
        else
        {
            vc_label = GetDsL3EditMpls3W(V, label_f, &dsl3edit);
        }
        sal_sprintf(vc_label_str, "%u", vc_label);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s%-15s%-13u%-9s%-10s%s\n",
                       nh_str, "MPLS", p_mpls_info->tunnel_id, vc_label_str, aps_group_str,  "N");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s%-15s%-13u%-9s%-10s%s\n",
                       nh_str, "MPLS", p_mpls_info->tunnel_id, vc_label_str, "-", "-");
    }

    sys_usw_nh_dump_xvlan(lchip, nhid, detail);


    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_get_tunnel_info(uint8 lchip, sys_nh_info_ip_tunnel_t* p_nhinfo, char* tunnel_type,
                                       char* ipsa, char * ipda, char * gre_key)
{
    uint32 tempip = 0;
    ipv6_addr_t sw_ipv6_address;
    uint32 ip_da = 0;
    uint32 ip_sa = 0;
    uint8  ip_isv6    = 0;
    char   str[35];
    char   format[10];
    char*  tunnel_type_name[] = {
        "-",             "IPv4-in-IPv4",  "IPv6-in-IPv4",  "IPv4-in-IPv6",
        "IPv6-in-IPv6",  "GRE-in-IPv4",   "GRE-in-IPv6",   "ISATAP",
        "6TO4",          "6RD",           "NAT", "NAT66",  "IVI_6TO4",
        "IVI_4TO6",      "NVGRE-in-IPv4", "VXLAN-in-IPv4", "GENEVE-in-IPv4",
        "NVGRE-in-IPv6", "VXLAN-in-IPv6", "GENEVE-in-IPv6"
    };
    ctc_ip_tunnel_nh_param_t p_tunnel_info;
    sal_memcpy(tunnel_type, "-", sal_strlen("-"));
    sal_memcpy(ipsa, "-", sal_strlen("-"));
    sal_memcpy(ipda, "-", sal_strlen("-"));
    sal_memcpy(gre_key, "-", sal_strlen("-"));
    sal_memset(&p_tunnel_info, 0, sizeof(p_tunnel_info));
    sys_usw_nh_get_ip_tunnel_cb(lchip,(sys_nh_info_com_t*)p_nhinfo,&p_tunnel_info);
    if (p_nhinfo->flag & SYS_NH_IP_TUNNEL_FLAG_NAT64)
    {
        sal_memcpy(tunnel_type, (p_tunnel_info.tunnel_info.tunnel_type == CTC_TUNNEL_TYPE_IPV4_NAT) ? "NAT64" : "NAT46", sal_strlen("NAT64"));
    }
    else
    {
        sal_memcpy(tunnel_type, tunnel_type_name[p_tunnel_info.tunnel_info.tunnel_type], sal_strlen(tunnel_type_name[p_tunnel_info.tunnel_info.tunnel_type]));
    }

    switch (p_tunnel_info.tunnel_info.tunnel_type)
    {
    case CTC_TUNNEL_TYPE_IPV4_IN4:
    case CTC_TUNNEL_TYPE_IPV6_IN4:
    case CTC_TUNNEL_TYPE_NVGRE_IN4:
    case CTC_TUNNEL_TYPE_VXLAN_IN4:
    case CTC_TUNNEL_TYPE_6RD:
    case CTC_TUNNEL_TYPE_IPV4_NAT:
        ip_da = p_tunnel_info.tunnel_info.ip_da.ipv4;
        ip_sa = p_tunnel_info.tunnel_info.ip_sa.ipv4;
        break;
    case CTC_TUNNEL_TYPE_GRE_IN4:
        if (CTC_FLAG_ISSET(p_tunnel_info.tunnel_info.flag, CTC_IP_NH_TUNNEL_FLAG_GRE_WITH_KEY))
        {
            if(p_tunnel_info.tunnel_info.gre_info.gre_key)
                sal_sprintf(gre_key, "%s", CTC_DEBUG_HEX_FORMAT(str, format, p_tunnel_info.tunnel_info.gre_info.gre_key, 8, U));
        }
        ip_sa = p_tunnel_info.tunnel_info.ip_sa.ipv4;
        ip_da = p_tunnel_info.tunnel_info.ip_da.ipv4;
        break;
    case CTC_TUNNEL_TYPE_ISATAP:
        ip_sa = p_tunnel_info.tunnel_info.ip_sa.ipv4;
        break;
    case CTC_TUNNEL_TYPE_6TO4:
        if (CTC_FLAG_ISSET(p_tunnel_info.tunnel_info.flag, CTC_IP_NH_TUNNEL_FLAG_6TO4_USE_MANUAL_IPSA))
        {
            ip_sa = p_tunnel_info.tunnel_info.ip_sa.ipv4;
        }
        break;
    case CTC_TUNNEL_TYPE_IPV4_IN6:
    case CTC_TUNNEL_TYPE_IPV6_IN6:
    case CTC_TUNNEL_TYPE_VXLAN_IN6:
    case CTC_TUNNEL_TYPE_NVGRE_IN6:
    case CTC_TUNNEL_TYPE_IPV6_NAT:
        ip_isv6 = 1;
        sal_memset(&sw_ipv6_address, 0, sizeof(ipv6_addr_t));
        sw_ipv6_address[0] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[0]);
        sw_ipv6_address[1] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[1]);
        sw_ipv6_address[2] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[2]);
        sw_ipv6_address[3] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[3]);
        sal_inet_ntop(AF_INET6, sw_ipv6_address, ipda, CTC_IPV6_ADDR_STR_LEN);
        sal_memset(&sw_ipv6_address, 0, sizeof(ipv6_addr_t));
        sw_ipv6_address[0] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[0]);
        sw_ipv6_address[1] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[1]);
        sw_ipv6_address[2] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[2]);
        sw_ipv6_address[3] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[3]);
        sal_inet_ntop(AF_INET6, sw_ipv6_address, ipsa, CTC_IPV6_ADDR_STR_LEN);
        break;
    case CTC_TUNNEL_TYPE_GRE_IN6:
        ip_isv6 = 1;
        sal_memset(&sw_ipv6_address, 0, sizeof(ipv6_addr_t));
        sw_ipv6_address[0] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[0]);
        sw_ipv6_address[1] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[1]);
        sw_ipv6_address[2] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[2]);
        sw_ipv6_address[3] = sal_ntohl(p_tunnel_info.tunnel_info.ip_da.ipv6[3]);
        sal_inet_ntop(AF_INET6, sw_ipv6_address, ipda, CTC_IPV6_ADDR_STR_LEN);
        sal_memset(&sw_ipv6_address, 0, sizeof(ipv6_addr_t));
        sw_ipv6_address[0] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[0]);
        sw_ipv6_address[1] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[1]);
        sw_ipv6_address[2] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[2]);
        sw_ipv6_address[3] = sal_ntohl(p_tunnel_info.tunnel_info.ip_sa.ipv6[3]);
        sal_inet_ntop(AF_INET6, sw_ipv6_address, ipsa, CTC_IPV6_ADDR_STR_LEN);
        if(p_tunnel_info.tunnel_info.gre_info.gre_key)
            sal_sprintf(gre_key, "%s", CTC_DEBUG_HEX_FORMAT(str, format, p_tunnel_info.tunnel_info.gre_info.gre_key, 8, U));
        break;
    default:
        break;
    }
    if(!ip_isv6)
    {
        tempip = sal_ntohl(ip_da);
        sal_inet_ntop(AF_INET, &tempip, ipda, CTC_IPV6_ADDR_STR_LEN);
        tempip = sal_ntohl(ip_sa);
        sal_inet_ntop(AF_INET, &tempip, ipsa, CTC_IPV6_ADDR_STR_LEN);
    }

    if (0 == sal_strcmp(ipda, "0.0.0.0"))
    {
        sal_sprintf(ipda, "%s", "-");
    }

    if (0 == sal_strcmp(ipsa, "0.0.0.0"))
    {
        sal_sprintf(ipsa, "%s", "-");
    }

    if (0 == sal_strcmp(ipda, "::"))
    {
        sal_sprintf(ipda, "%s", "-");
    }

    if (0 == sal_strcmp(ipsa, "::"))
    {
        sal_sprintf(ipsa, "%s", "-");
    }
    if(p_tunnel_info.tunnel_info.masklen)
    {
        sal_sprintf(ipda + sal_strlen(ipda), "/%d", p_tunnel_info.tunnel_info.masklen);
    }

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_ip_tunnel_brief(uint8 lchip, uint32 nhid,sys_nh_info_ip_tunnel_t* p_nhinfo)
{
    uint32 cmd;

    int32 ret = CTC_E_NONE;
    sys_l3if_prop_t l3if_prop;

    char tunnel_type[32] = {0};
    char ipda[200] = {0};
    char ipsa[200] = {0};
    char gre_key[40] = {0};
    uint16 lport = 0;
    DsL2Edit3WOuter_m dsl2edit3w;
    DsL2Edit6WOuter_m dsl2edit6w;
    hw_mac_addr_t hw_mac;
    mac_addr_t user_mac;

    char str[35];
    char format[10];
    uint32 offset = 0;
    char  nh_str[30] = {0};

    sys_usw_nh_dump_get_tunnel_info(lchip, p_nhinfo, tunnel_type, ipsa, ipda, gre_key);
    if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "%-8u%-15s%-15s%-11s%-8s%-8s%-17s%-18s%-18s%s\n",
                       nhid, "IP-Tunnel", "-", "-", "-", "-", "-", "-", "-", "-");
        return CTC_E_NONE;
    }


    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "IP-Tunnel");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", tunnel_type);

    CTC_ERROR_RETURN(sys_usw_internal_port_get_rsv_port(lchip, SYS_INTERNAL_PORT_TYPE_IP_TUNNEL, 0, &lport))

    if( CTC_FLAG_ISSET(p_nhinfo->flag, SYS_NH_IP_TUNNEL_REROUTE))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", "RE-ROUTE");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", CTC_DEBUG_HEX_FORMAT(str, format, p_nhinfo->gport, 4, U));

        l3if_prop.l3if_id = p_nhinfo->l3ifid;
        ret = sys_usw_l3if_get_l3if_info(lchip, 1, &l3if_prop);
        if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_USE_ECMP_IF))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", p_nhinfo->l3ifid);
        }
        else if (CTC_E_NONE != ret)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", l3if_prop.vlan_id);
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", l3if_prop.l3if_id);
        }
    }

    if(p_nhinfo->arp_id)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17d", p_nhinfo->arp_id);
    }
    else
    {
        sal_memset(&user_mac, 0, sizeof(user_mac));

        if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_L2EDIT))
        {
            sal_memset(&hw_mac, 0, sizeof(hw_mac));
            sal_memset(&dsl2edit3w, 0, sizeof(DsL2Edit3WOuter_m));
            sal_memset(&dsl2edit6w, 0, sizeof(DsL2Edit6WOuter_m));

            offset = p_nhinfo->outer_l2_edit_offset;
            if (offset >= MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM))
            {
                cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, (offset - MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM)) / 2, cmd, &dsl2edit6w));
            }
            else
            {
                cmd = DRV_IOR(DsL2Edit6WOuter_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, offset / 2, cmd, &dsl2edit6w));
            }

            if (0 == offset % 2)
            {
                sal_memcpy(&dsl2edit3w, &dsl2edit6w, DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2);
            }
            else
            {
                sal_memcpy(&dsl2edit3w, (uint8*)&dsl2edit6w + DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2, DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2);
            }
            if (DRV_FROM_TMM(lchip))
            {
                GetDsL2EditAddEth1X(A, macDa_f, &dsl2edit3w, hw_mac);
            }
            else
            {
                GetDsL2EditEth3W(A, macDa_f, &dsl2edit3w, hw_mac);
            }
            SYS_USW_SET_USER_MAC(user_mac, hw_mac);
        }

        if ((0 == user_mac[0]) && (0 == user_mac[1])
            && (0 == user_mac[2]) && (0 == user_mac[3])
            && (0 == user_mac[4]) && (0 == user_mac[5]))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17s", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17s", sys_output_mac(user_mac));
        }
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-36s", ipsa);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-2s", gre_key);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%82s%-18s"," ", ipda);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_ip_tunnel(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_ip_tunnel_t* p_ip_tunnel_info;
    sys_nh_info_com_t* p_nhinfo = NULL;

    int32 ret;


    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (CTC_E_NOT_EXIST == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  IP tunnel nexthop %u not exist\n", nhid);
        return CTC_E_NONE;
    }
    else if (CTC_E_INVALID_PARAM == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Invalid nexthopId %u\n", nhid);
        return CTC_E_NONE;
    }
    else
    {
        CTC_ERROR_RETURN(ret);
    }

    if (SYS_NH_TYPE_IP_TUNNEL != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't IP tunnel nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_ip_tunnel_info = (sys_nh_info_ip_tunnel_t*)(p_nhinfo);

    if (p_ip_tunnel_info->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_IP_TUNNEL;
    }
    CTC_ERROR_RETURN(sys_usw_nh_dump_ip_tunnel_brief(lchip, nhid,p_ip_tunnel_info));

    return CTC_E_NONE;
}

int32
sys_usw_nh_wlan_tunnel_dump_get_tunnel_info(uint8 lchip, sys_nh_info_wlan_tunnel_t* p_nhinfo, char* tunnel_type,
                                       char* ipsa, char* ipda, char* src_port, char* dest_port)
{
    uint32 l3edit_offset = p_nhinfo->dsl3edit_offset;
    DsL3EditTunnelV4_m  dsl3edit_v4;
    DsL3EditTunnelV6_m  dsl3edit_v6;
    uint32 cmd = 0;

    uint32 tempip = 0;
    DsL3TunnelV4IpSa_m v4_sa;
    DsL3TunnelV6IpSa_m v6_sa;
    ipv6_addr_t hw_ipv6_address;
    ipv6_addr_t sw_ipv6_address;
    uint8 ipsa_index = 0;
    uint32 ip_da = 0;
    uint32 ip_sa = 0;
    uint16 l4_src_port = 0;
    uint16 l4_dest_port = 0;
    char   str[35];
    char   format[10];

    sal_memcpy(tunnel_type, "-", sal_strlen("-"));
    sal_memcpy(ipsa, "-", sal_strlen("-"));
    sal_memcpy(ipda, "-", sal_strlen("-"));
    sal_memcpy(src_port, "-", sal_strlen("-"));
    sal_memcpy(dest_port, "-", sal_strlen("-"));

       if (p_nhinfo->flag & SYS_NH_WLAN_TUNNEL_FLAG_IN_V4)
        {
            cmd = DRV_IOR(DsL3EditTunnelV4_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, l3edit_offset, cmd, &dsl3edit_v4));

            ipsa_index = GetDsL3EditTunnelV4(V, ipSaIndex_f, &dsl3edit_v4);
            ip_da = GetDsL3EditTunnelV4(V, ipDa_f, &dsl3edit_v4);
            cmd = DRV_IOR(DsL3TunnelV4IpSa_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, ipsa_index, cmd, &v4_sa));
            ip_sa = GetDsL3TunnelV4IpSa(V, ipSa_f, &v4_sa);
            sal_memcpy(tunnel_type, "TUNNEL-IPv4", sal_strlen("TUNNEL-IPv4"));
            l4_src_port = GetDsL3EditTunnelV4(V, udpDestPort_f, &dsl3edit_v4);
            l4_dest_port = GetDsL3EditTunnelV4(V, udpSrcPort_f, &dsl3edit_v4);
            sal_sprintf(src_port, "%s", CTC_DEBUG_HEX_FORMAT(str, format, l4_src_port, 4, U));
            sal_sprintf(dest_port, "%s", CTC_DEBUG_HEX_FORMAT(str, format, l4_dest_port, 4, U));
            tempip = sal_ntohl(ip_sa);
            sal_inet_ntop(AF_INET, &tempip, ipsa, CTC_IPV6_ADDR_STR_LEN);

            tempip = sal_ntohl(ip_da);
            sal_inet_ntop(AF_INET, &tempip, ipda, CTC_IPV6_ADDR_STR_LEN);

        }
       else  if (p_nhinfo->flag & SYS_NH_WLAN_TUNNEL_FLAG_IN_V6)
        {
            cmd = DRV_IOR(DsL3EditTunnelV6_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, l3edit_offset, cmd, &dsl3edit_v6));

            sal_memcpy(tunnel_type, "TUNNEL-IPv6", sal_strlen("TUNNEL-IPv6"));
            l4_src_port = GetDsL3EditTunnelV6(V, udpDestPort_f, &dsl3edit_v6);
            l4_dest_port = GetDsL3EditTunnelV6(V, udpSrcPort_f, &dsl3edit_v6);
            sal_sprintf(src_port, "%s", CTC_DEBUG_HEX_FORMAT(str, format, l4_src_port, 4, U));
            sal_sprintf(dest_port, "%s", CTC_DEBUG_HEX_FORMAT(str, format, l4_dest_port, 4, U));
            ipsa_index = GetDsL3EditTunnelV6(V, ipSaIndex_f, &dsl3edit_v6);
            sal_memset(&hw_ipv6_address, 0, sizeof(ipv6_addr_t));
            sal_memset(&sw_ipv6_address, 0, sizeof(ipv6_addr_t));

            GetDsL3EditTunnelV6(A, ipDa_f, &dsl3edit_v6, hw_ipv6_address);

            sw_ipv6_address[0] = sal_ntohl(hw_ipv6_address[3]);
            sw_ipv6_address[1] = sal_ntohl(hw_ipv6_address[2]);
            sw_ipv6_address[2] = sal_ntohl(hw_ipv6_address[1]);
            sw_ipv6_address[3] = sal_ntohl(hw_ipv6_address[0]);

            sal_inet_ntop(AF_INET6, sw_ipv6_address, ipda, CTC_IPV6_ADDR_STR_LEN);

            cmd = DRV_IOR(DsL3TunnelV6IpSa_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, ipsa_index, cmd, &v6_sa));

            sal_memset(&hw_ipv6_address, 0, sizeof(ipv6_addr_t));
            sal_memset(&sw_ipv6_address, 0, sizeof(ipv6_addr_t));

            GetDsL3TunnelV6IpSa(A, ipSa_f, &v6_sa, hw_ipv6_address);

            sw_ipv6_address[0] = sal_ntohl(hw_ipv6_address[3]);
            sw_ipv6_address[1] = sal_ntohl(hw_ipv6_address[2]);
            sw_ipv6_address[2] = sal_ntohl(hw_ipv6_address[1]);
            sw_ipv6_address[3] = sal_ntohl(hw_ipv6_address[0]);

            sal_inet_ntop(AF_INET6, sw_ipv6_address, ipsa, CTC_IPV6_ADDR_STR_LEN);

        }

    if (0 == sal_strcmp(ipda, "0.0.0.0"))
    {
        sal_sprintf(ipda, "%s", "-");
    }

    if (0 == sal_strcmp(ipsa, "0.0.0.0"))
    {
        sal_sprintf(ipsa, "%s", "-");
    }

    if (0 == sal_strcmp(ipda, "::"))
    {
        sal_sprintf(ipda, "%s", "-");
    }

    if (0 == sal_strcmp(ipsa, "::"))
    {
        sal_sprintf(ipsa, "%s", "-");
    }

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_wlan_tunnel_brief(uint8 lchip, uint32 nhid,sys_nh_info_wlan_tunnel_t* p_nhinfo)
{

    char tunnel_type[32] = {0};
    char ipda[200] = {0};
    char ipsa[200] = {0};
    char src_port[40] = {0};
    char dest_port[40] = {0};
    char  nh_str[30] = {0};


    sys_usw_nh_wlan_tunnel_dump_get_tunnel_info(lchip, p_nhinfo, tunnel_type, ipsa, ipda, src_port, dest_port);
    if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "%-8u%-15s%-15s%-11s%-8s%-8s%-17s%-18s%-18s%s\n",
                       nhid, "WLAN-Tunnel", "-", "-", "-", "-", "-", "-", "-", "-");
        return CTC_E_NONE;
    }

    NHID_CONVERT_STR(nhid, nh_str);

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", nhid);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "WLAN-Tunnel");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", tunnel_type);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", dest_port);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", src_port);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-36s", ipsa);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%s", "-");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%60s%-18s"," ", ipda);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_wlan_tunnel(uint8 lchip, uint32 nhid, uint8 detail)
{
    sys_nh_info_wlan_tunnel_t* p_wlan_tunnel_info;
    sys_nh_info_com_t* p_nhinfo = NULL;

    int32 ret;


    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (CTC_E_NOT_EXIST == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  Wlan tunnel nexthop %u not exist\n", nhid);
        return CTC_E_NONE;
    }
    else if (CTC_E_INVALID_PARAM == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Invalid nexthopId %u\n", nhid);
        return CTC_E_NONE;
    }
    else
    {
        CTC_ERROR_RETURN(ret);
    }

    if (SYS_NH_TYPE_WLAN_TUNNEL != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't Wlan tunnel nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_wlan_tunnel_info = (sys_nh_info_wlan_tunnel_t*)(p_nhinfo);
    CTC_ERROR_RETURN(sys_usw_nh_dump_wlan_tunnel_brief(lchip, nhid, p_wlan_tunnel_info));

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_srv6(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_srv6_t* p_srv6_info;
    sys_nh_info_com_t* p_nhinfo = NULL;
    int32 ret;
    uint16 lport = 0;
    sys_l3if_prop_t l3if_prop;
    char str[35] = {0};
    char format[10] = {0};
    char  nh_str[30] = {0};
    char ip_addr[128] = {0};
    DsL2Edit3WOuter_m dsl2edit3w;
    DsL2Edit6WOuter_m dsl2edit6w;
    hw_mac_addr_t hw_mac;
    mac_addr_t user_mac;
    uint32 offset = 0;
    uint32 cmd = 0;
    ipv6_addr_t hw_ipv6_address;
    ipv6_addr_t sw_ipv6_address;
    char* type[] = {"E-INSERT", "E-ENCAPS", "H-INSERT",  "H-ENCAPS", "H-ENCAPS-L2"};
    sys_nh_db_srh_t    *p_srh_tnl = NULL;

    sal_memset(hw_ipv6_address, 0, sizeof(hw_ipv6_address));
    sal_memset(sw_ipv6_address, 0, sizeof(sw_ipv6_address));
    sal_memset(ip_addr, 0, sizeof(ip_addr));

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (CTC_E_NOT_EXIST == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  SRv6 nexthop %u not exist\n", nhid);
        return CTC_E_NONE;
    }
    else if (CTC_E_INVALID_PARAM == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Invalid nexthopId %u\n", nhid);
        return CTC_E_NONE;
    }
    else
    {
        CTC_ERROR_RETURN(ret);
    }

    p_srv6_info = (sys_nh_info_srv6_t*)(p_nhinfo);
    if (p_srv6_info->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_IP_TUNNEL;
    }

    if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "\n%-8u%-15s%-11s%-8s%-8s%-12s%-12s%-12s\n",
                       nhid, "-", "-", "-", "-", "-", "-", "-");
        return CTC_E_NONE;
    }


    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", type[p_srv6_info->srv6_type]);

    CTC_ERROR_RETURN(sys_usw_internal_port_get_rsv_port(lchip, SYS_INTERNAL_PORT_TYPE_IP_TUNNEL, 0, &lport))
    p_srh_tnl = _sys_usw_nh_lkup_srh_id(lchip, p_srv6_info->srh_id);
    if( CTC_FLAG_ISSET(p_srv6_info->flag, SYS_NH_SRV6_FLAG_REROUTE))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", "RE-ROUTE");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
    }
    else
    {
        if (p_srh_tnl && !CTC_FLAG_ISSET(p_srh_tnl->flag, SYS_NH_SRH_FLAG_APS))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", CTC_DEBUG_HEX_FORMAT(str, format, p_srv6_info->gport, 4, U));
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-11s", "-");
        }
        l3if_prop.l3if_id = p_srv6_info->l3ifid;
        ret = sys_usw_l3if_get_l3if_info(lchip, 1, &l3if_prop);
        if (CTC_E_NONE != ret)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", l3if_prop.vlan_id);
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", l3if_prop.l3if_id);
        }
    }

    if(p_srh_tnl && p_srh_tnl->arp_id)
    {
        if(!CTC_FLAG_ISSET(p_srh_tnl->flag, SYS_NH_SRH_FLAG_APS))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12d", p_srh_tnl->arp_id);
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", "-");
        }
    }
    else
    {
        sal_memset(&user_mac, 0, sizeof(user_mac));
        if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_HAVE_L2EDIT))
        {
            sal_memset(&hw_mac, 0, sizeof(hw_mac));
            sal_memset(&dsl2edit3w, 0, sizeof(DsL2Edit3WOuter_m));
            sal_memset(&dsl2edit6w, 0, sizeof(DsL2Edit6WOuter_m));
            offset = p_srv6_info->outer_l2_edit_offset;
            if (offset >= MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM))
            {
                cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, (offset - MCHIP_CAP(SYS_CAP_NH_OUTER_L2_EDIT_NUM)) / 2, cmd, &dsl2edit6w));
            }
            else
            {
                cmd = DRV_IOR(DsL2Edit6WOuter_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, offset / 2, cmd, &dsl2edit6w));
            }

            if (0 == offset % 2)
            {
                sal_memcpy(&dsl2edit3w, &dsl2edit6w, DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2);
            }
            else
            {
                sal_memcpy(&dsl2edit3w, (uint8*)&dsl2edit6w + DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2, DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2);
            }

            GetDsL2EditAddEth(A, macDa_f, &dsl2edit3w, hw_mac);
            SYS_USW_SET_USER_MAC(user_mac, hw_mac);
        }
        if ((0 == user_mac[0]) && (0 == user_mac[1])
            && (0 == user_mac[2]) && (0 == user_mac[3])
            && (0 == user_mac[4]) && (0 == user_mac[5]))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", sys_output_mac(user_mac));
        }
    }

    if(p_srh_tnl && p_srh_tnl->srh_id)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12u", p_srh_tnl->srh_id);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12u", p_srh_tnl->num);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", "-");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", "-");
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");
    return CTC_E_NONE;
}
int32
sys_usw_nh_dump_trill_brief(uint8 lchip, uint32 nhid,sys_nh_info_trill_t* p_nhinfo)
{
    char  nh_str[30] = {0};

    if (CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                      "%-8u%-10s%-12s%-20s%-18s%-18s\n",
                       nhid, "TRILL", "-", "-", "-", "-");
        return CTC_E_NONE;
    }

    NHID_CONVERT_STR(nhid, nh_str);

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", nhid);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10s", "TRILL");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%.4x      ", p_nhinfo->gport);
    if (p_nhinfo->l2_edit_ptr)
    {
        sys_dsl2edit_eth_t   dsl2edit;
        sal_memset(&dsl2edit, 0, sizeof(dsl2edit));
        CTC_ERROR_RETURN(sys_usw_nh_read_asic_table(lchip, SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_4W, p_nhinfo->l2_edit_ptr, &dsl2edit));
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", sys_output_mac(dsl2edit.mac_da));
    }
    else
    {
         SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", "-");
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-18d", p_nhinfo->egress_nickname);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-18d", p_nhinfo->ingress_nickname);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

    return CTC_E_NONE;
}


int32
sys_usw_nh_dump_trill(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_trill_t* p_trill_info;
    sys_nh_info_com_t* p_nhinfo = NULL;

    int32 ret;


    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo));
    if (CTC_E_NOT_EXIST == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  TRILL nexthop %u not exist\n", nhid);
        return CTC_E_NONE;
    }
    else if (CTC_E_INVALID_PARAM == ret)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Invalid nexthopId %u\n", nhid);
        return CTC_E_NONE;
    }
    else
    {
        CTC_ERROR_RETURN(ret);
    }

    if (SYS_NH_TYPE_TRILL != p_nhinfo->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't TRILL nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }

    p_trill_info = (sys_nh_info_trill_t*)(p_nhinfo);
    if (p_trill_info->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_TRILL;
    }
    CTC_ERROR_RETURN(sys_usw_nh_dump_trill_brief(lchip, nhid,p_trill_info));

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_mpls_tunnel(uint8 lchip, uint16 tunnel_id, uint8 detail)
{
    sys_nh_db_mpls_tunnel_t* p_mpls_tunnel;
    int32 ret = 0;
    DsL2Edit6WOuter_m dsl2edit;
    ds0_t  dsl3editmpls;
    DsApsBridge_m ds_aps_bridge;
    hw_mac_addr_t hw_mac;
    mac_addr_t sw_mac;
    sys_l3if_prop_t l3if_prop;
    uint32 offset = 0;
    uint32 lsp_label = 0, spme_label = 0;
    uint8  exist_spme = 0;
    uint8 l2edit_type = 0;
    uint32  gport;
    uint16  l3if_id;
    char p_port[16]={0};
    uint8 gchip = 0;
    uint8 is_6w = 0;
    uint8 is_sr = 0;
    sys_nh_db_arp_t *p_arp ;

    sal_memset(&dsl2edit, 0, sizeof(DsL2Edit6WOuter_m));
    sal_memset(&dsl3editmpls, 0, sizeof(dsl3editmpls));
    sal_memset(&ds_aps_bridge, 0, sizeof(DsApsBridge_m));
    sal_memset(&hw_mac, 0, sizeof(hw_mac_addr_t));

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;

    sys_usw_get_gchip_id(lchip, &gchip);
    CTC_ERROR_GOTO(sys_usw_nh_lkup_mpls_tunnel(lchip, tunnel_id, &p_mpls_tunnel), ret, error_proc);

    if (!p_mpls_tunnel)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% MPLS Tunnel is not exist \n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, " Entry not exist \n");
		ret = CTC_E_NOT_EXIST;
        goto error_proc;
    }

    if (CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_APS))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14s%-11s%-13s%-13s\n",
                   "TUNNEL_ID", "APS_GRP", "W_PATH", "P_PATH");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "----------------------------------------------------\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14u%-11u%-13u%-13u \n", tunnel_id, p_mpls_tunnel->gport, p_mpls_tunnel->l3ifid, p_mpls_tunnel->p_l3ifid);
        SYS_NH_UNLOCK;

        return CTC_E_NONE;
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14s%-13s%-9s%-14s%-17s%-8s%-9s%s\n",
                   "TUNNEL_ID", "DESTPORT", "VLAN", "L3IFID", "MACDA/ARPID", "LSP", "SPME", "ACTIVE");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "----------------------------------------------------------------------------------------------------\n");

    if(p_mpls_tunnel->arp_id)
    {
       p_arp= sys_usw_nh_lkup_arp_id(lchip, p_mpls_tunnel->arp_id);
       if (NULL == p_arp)
       {
           SYS_NH_UNLOCK;
           return CTC_E_NOT_EXIST;
       }
       gport = ((CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_REDIRECT_TO_CPU))?CTC_GPORT_RCPU(gchip):p_arp->gport);
       l3if_id = p_arp->l3if_id;
    }
    else
    {
        gport = p_mpls_tunnel->gport;
        l3if_id = p_mpls_tunnel->l3ifid;
    }

    offset = p_mpls_tunnel->lsp_offset;
    CTC_ERROR_GOTO(sys_usw_nh_get_asic_table(lchip, SYS_NH_ENTRY_TYPE_L3EDIT_MPLS, offset, &dsl3editmpls), ret, error_proc);
    if (DRV_FROM_TMM(lchip))
    {
        lsp_label = GetDsL3EditAddMpls1X(V, label_f, &dsl3editmpls);
    }
    else
    {
        lsp_label = GetDsL3EditMpls3WLsp(V, label_f, &dsl3editmpls);
    }

    /* SPME */
    if (CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_EXSIT_SPME))
    {
        offset = p_mpls_tunnel->spme_offset;
    }
    else if (CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_IS_SPME))
    {
        offset = p_mpls_tunnel->lsp_offset;
    }
    else
    {
        offset = 0;
    }

    if (offset)
    {
        DsL3Edit6W3rd_m l3edit6w;
        sal_memset(&l3edit6w, 0, sizeof(l3edit6w));
        CTC_ERROR_GOTO(sys_usw_nh_get_asic_table(lchip, SYS_NH_ENTRY_TYPE_L3EDIT_SPME,
                                                          offset, &l3edit6w), ret, error_proc);
        if (offset % 2 == 0)
        {
            sal_memcpy(&dsl3editmpls, (uint8*)&l3edit6w,  DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W3rd_t)/2);
        }
        else
        {
            sal_memcpy( &dsl3editmpls, (uint8*)&l3edit6w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W3rd_t)/2, DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W3rd_t)/2);
        }
        if (DRV_FROM_TMM(lchip))
        {
            spme_label = GetDsL3EditAddMpls1X(V, label_f, &dsl3editmpls);
        }
        else
        {
            spme_label = GetDsL3EditMpls3W(V, label_f, &dsl3editmpls);
        }
        exist_spme = 1;
    }
    else
    {
        exist_spme = 0;
    }

    /* L2Edit */
    offset = p_mpls_tunnel->l2edit_offset;
    CTC_ERROR_GOTO(sys_usw_nh_get_asic_table(lchip, SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_4W,
                                                      offset, &dsl2edit), ret, error_proc);
    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
    {
        l2edit_type = GetDsL2Edit6WOuter(V, l2RewriteType_f, &dsl2edit);
        is_6w = (l2edit_type == 3);
    }
    else
    {
        l2edit_type = GetDsL2Edit6WOuter(V, l2EditType_f, &dsl2edit);
        is_6w = (l2edit_type == DRV_ENUM(DRV_L2EDITTYPE_ADDETH2X));
    }

    if (is_6w)
    {
        if (DRV_FROM_TMM(lchip))
        {
            GetDsL2EditAddEth(A, macDa_f, &dsl2edit, hw_mac);
        }
        else
        {
            GetDsL2Edit6WOuter(A, macDa_f, &dsl2edit, hw_mac);
        }
    }
    else
    {
        DsL2Edit3WOuter_m dsl2edit_3w;

        if ((offset%2) == 0)
        {
            sal_memcpy(&dsl2edit_3w, (uint8*)&dsl2edit,  DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2);
        }
        else
        {
            sal_memcpy( &dsl2edit_3w, (uint8*)&dsl2edit + DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2, DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit6WOuter_t)/2);
        }
        if (DRV_FROM_TMM(lchip))
        {
            if (l2edit_type != DRV_ENUM(DRV_L2EDITTYPE_LOOPBACK))
            {
                GetDsL2EditAddEth1X(A, macDa_f, &dsl2edit_3w, hw_mac);
            }
        }
        else
        {
            GetDsL2EditEth3W(A, macDa_f, &dsl2edit_3w, hw_mac);
        }
    }
    SYS_USW_SET_USER_MAC(sw_mac, hw_mac);

    /* dump mpls tunnel in brief */
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14u", tunnel_id);

    /* work path */
    sal_sprintf(p_port, "0x%04x", gport);

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-13s", p_mpls_tunnel->loop_nhid?"-":p_port);

    l3if_prop.l3if_id = l3if_id;
    ret =  sys_usw_l3if_get_l3if_info(lchip, 1, &l3if_prop);
    if (CTC_E_NONE != ret)
    {
        ret = CTC_E_NONE;
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8s", "-");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14s", "-");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9u",  l3if_prop.vlan_id);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-14u", l3if_prop.l3if_id);
    }

    if (p_mpls_tunnel->loop_nhid)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17s", "-");
    }
    else if(p_mpls_tunnel->arp_id)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17d", p_mpls_tunnel->arp_id);
    }
    else
    {
        if ((0 == sw_mac[0]) && (0 == sw_mac[1]) && (0 == sw_mac[2])
            && (0 == sw_mac[3]) && (0 == sw_mac[4]) && (0 == sw_mac[5]))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17s", "-");
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-17s", sys_output_mac(sw_mac));
        }
    }
    is_sr = CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_IS_SR)?1:0;
    if ((!p_mpls_tunnel->label_num) || is_sr)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-7s ", "-");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-7u ", lsp_label);
    }

    if ((exist_spme) &&  (!is_sr))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9u", spme_label);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-9s", "-");
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-5s\n", "Y");

    if (TRUE == detail)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "----------------------------------------------------------------------------------------------------\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------\n");

             if (!CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_IS_SPME)&&p_mpls_tunnel->label_num)
             {
                 if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
                 {
                     SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", is_sr? "DsL3EditMpls12W" : "DsL3EditMpls3W",  \
                     p_mpls_tunnel->lsp_offset, is_sr?( "SR"):("Lsp"));
                 }
                 else
                 {
                    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", is_sr?
                        "DsL3EditAddMpls4X" : "DsL3EditAddMpls1X",  \
                     p_mpls_tunnel->lsp_offset, is_sr?("SR"):("Lsp"));
                 }
             }

            /* SPME */
            if (CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_EXSIT_SPME))
            {
                offset = p_mpls_tunnel->spme_offset;
            }
            else if (CTC_FLAG_ISSET(p_mpls_tunnel->flag, SYS_NH_MPLS_TUNNEL_FLAG_IS_SPME))
            {
                offset = p_mpls_tunnel->lsp_offset;
            }
            else
            {
                offset = 0;
            }

            if (offset)
            {
              SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u [%s]\n", "DsL3Edit3W3rd",offset, "SPME");
            }

            offset = p_mpls_tunnel->l2edit_offset;
            CTC_ERROR_GOTO(sys_usw_nh_get_asic_table(lchip, SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_4W, offset, &dsl2edit), ret, error_proc);
            l2edit_type = GetDsL2Edit6WOuter(V, l2RewriteType_f, &dsl2edit);
            if (l2edit_type == SYS_NH_L2EDIT_TYPE_ETH_8W)
            {
                offset = p_mpls_tunnel->lsp_offset;
            }
            else
            {
                offset = 0;
            }

            if (offset)
            {
              SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "--%-20s :%u [%s]\n", "DsL3Edit3W3rd",offset,"SPME");
            }
            _sys_usw_nh_dump_l2edit_outer(lchip, p_mpls_tunnel->l2edit_offset);
    }

error_proc:
    SYS_NH_UNLOCK;
    return ret;
}

int32
sys_usw_nh_dump_misc(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_info_misc_t* p_nhinfo_misc;
    sys_nh_info_com_t* p_nhinfo_com = NULL;
    char  nh_str[30] = {0};
    int32 ret;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo_com));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }

    if (SYS_NH_TYPE_MISC != p_nhinfo_com->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't misc nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }
    NHID_CONVERT_STR(nhid, nh_str);

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", nhid);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "MISC");
    p_nhinfo_misc = (sys_nh_info_misc_t*)(p_nhinfo_com);
    if (CTC_IS_CPU_PORT(p_nhinfo_misc->gport))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%s", "CPU");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%-.4x", p_nhinfo_misc->gport);
    }
    if (CTC_MISC_NH_TYPE_TO_CPU == p_nhinfo_misc->misc_nh_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " (reason_id:%u)", p_nhinfo_misc->truncated_len);
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");

    if (p_nhinfo_misc->bind_data)
    {
        *p_bind_type = SYS_NH_TYPE_MISC;
    }
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_overlay(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    sys_nh_db_ol_tunnel_t* tunnel_db = NULL;
    sys_nh_info_com_t* p_nhinfo_com = NULL;
    sys_nh_info_overlay_t* p_overlay_info = NULL;
    char  nh_str[30] = {0};
    int32 ret;
    uint32 arp_id = 0;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo_com));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }
    if (SYS_NH_TYPE_OVERLAY != p_nhinfo_com->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't overlay nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }
    p_overlay_info = (sys_nh_info_overlay_t*)(p_nhinfo_com);
    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-8u", nhid);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15u", p_overlay_info->nhid);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10u", p_overlay_info->dest_logic_port);


    if (!p_overlay_info->ecmp_gid || CTC_FLAG_ISSET(p_overlay_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_USE_ECMP_IF))
    {
        tunnel_db = _sys_usw_nh_lkup_tunnel(lchip, p_overlay_info->dest_logic_port);
        arp_id = tunnel_db ? tunnel_db->arp_id : 0;
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10u", arp_id);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10u\n", p_overlay_info->ecmp_gid);
    return CTC_E_NONE;
}
int32
sys_usw_nh_dump_overlay_vni(uint8 lchip, uint32 nhid, uint8 detail, uint8* p_bind_type)
{
    ctc_nh_ol_vni_t nh_ol_vni;
    sys_nh_info_com_t* p_nhinfo_com = NULL;
    sys_nh_info_ol_vni_t* p_ol_vni = NULL;
    char  nh_str[30] = {0};
    int32 ret;
    char  vni_flag_str[15] = {0};
    char  buf2[2] = {0};
    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo_com));
    if (ret != CTC_E_NONE)
    {
        return ret;
    }
    if (SYS_NH_TYPE_OVERLAY_VNI!= p_nhinfo_com->hdr.nh_entry_type)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% Isn't overlay vni nexthop for nexthopId %u\n", nhid);
        return CTC_E_INVALID_PARAM;
    }
    p_ol_vni = (sys_nh_info_ol_vni_t*)(p_nhinfo_com);
    NHID_CONVERT_STR(nhid, nh_str);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%-10x", nhid);

    sal_memset(&nh_ol_vni, 0, sizeof(nh_ol_vni));
    CTC_ERROR_RETURN(sys_usw_nh_get_ol_vni(lchip, (sys_nh_info_com_t*)p_ol_vni, &nh_ol_vni));

    buf2[1] = '\0';
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_HOVERLAY))
    {
        buf2[0] = 'H';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_FID))
    {
        buf2[0] = 'F';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_STRIP_VLAN))
    {
        buf2[0] = 'S';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_STRIP_CVLAN))
    {
        buf2[0] = 'C';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_CROSS_VNI))
    {
        buf2[0] = 'V';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_UPDATE_MACSA))
    {
        buf2[0] = 'U';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_LOGIC_PORT_CHECK))
    {
        buf2[0] = 'L';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_TTL_NO_DEC))
    {
        buf2[0] = 'T';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_L3_OVERLAY))
    {
        buf2[0] = 'R';
        sal_strcat(vni_flag_str, buf2);
    }
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_LOGIC_PORT))
    {
        buf2[0] = 'B';
        sal_strcat(vni_flag_str, buf2);
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", vni_flag_str);
    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_FID))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15u", nh_ol_vni.fid);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-15s", "-");
    }

    if(CTC_FLAG_ISSET(nh_ol_vni.flag, CTC_NH_OL_VNI_FLAG_CROSS_VNI))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", sys_output_mac(nh_ol_vni.macda));
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", sys_output_mac(nh_ol_vni.macsa));
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%-20x", nh_ol_vni.inner_ether_type);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s%-20s%-20s", "-","-","-");
    }

    if(nh_ol_vni.cid)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20u", nh_ol_vni.cid);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-20s", "-");
    }

    return CTC_E_NONE;
}
void
sys_usw_nh_dump_head_by_type(uint8 lchip, uint32 nhid, sys_usw_nh_type_t nh_type, uint8 is_all)
{
    int32 ret;
    sys_nh_info_com_t* p_nh_com_info = NULL;

    ret = (sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid, (sys_nh_info_com_t**)&p_nh_com_info));
    if (ret != CTC_E_NONE)
    {
        return;
    }

    switch (nh_type)
    {
    case SYS_NH_TYPE_NULL:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nNHID is %u, Invalid Nexthop\n", nhid);
        break;

    case SYS_NH_TYPE_MCAST:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "Mcast Nexthop(I-Internal Nexthop):");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s%-15s%-15s%-15s\n", "NHID", "TYPE", "GROUP_ID", "LOGIC_REP");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-----------------------------------------------------------\n");
        break;

    case SYS_NH_TYPE_BRGUC:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "BridgeUc Nexthop(I-Internal Nexthop):");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s%-17s%-16s%-10s%-8s\n", "NHID", "TYPE", "SUB_TYPE", "DESTPORT", "ACTIVE");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------------------------------------\n");
        break;

    case SYS_NH_TYPE_IPUC:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "IPUC Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s%-13s%-9s%-10s%-16s%-8s\n", "NHID", "TYPE", "DESTPORT", "VLAN", "L3IFID", "MACDA/ARPID","ACTIVE");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "----------------------------------------------------------------------------------\n");
        break;

    case SYS_NH_TYPE_MPLS:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "MPLS Nexthop:");
        }
        if (!CTC_FLAG_ISSET(p_nh_com_info->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_MPLS_POP_NH))
        {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-9s%-9s%-14s%-13s%-14s%s\n", "NHID", "TYPE", "TUNNEL_ID", "VC_LABEL", "APS_GROUP", "ACTIVE");
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "--------------------------------------------------------------------------\n");

        }
        else
        {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s%-13s%-9s%-10s%s\n", "NHID", "TYPE", "DESTPORT", "VLAN", "L3IFID", "MACDA/ARPID");
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "----------------------------------------------------------------------------\n");
        }

        break;

    case SYS_NH_TYPE_ECMP:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "ECMP Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s\n", "NHID", "TYPE");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------\n");
        break;

    case SYS_NH_TYPE_ILOOP:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "Iloop Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s%-15s%s\n", "NHID", "TYPE", "LPBK_GPORT");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "----------------------------------------\n");
        break;

    case SYS_NH_TYPE_IP_TUNNEL:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "IP Tunnel Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "\n%-8s%-15s%-15s%-11s%-8s%-8s%-17s%-18s%-18s%s\n",
                       "NHID", "TYPE", "TUNNEL_TYPE", "DESTPORT", "VLAN", "L3IFID", "MACDA/ARPID", "IPSA/IPDA", " ", "GRE_KEY");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "--------------------------------------------------------------------------------------------------------------------------------\n");
        break;

    case SYS_NH_TYPE_TRILL:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "Trill Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "\n%-8s%-10s%-12s%-20s%-18s%-18s\n",
                       "NHID", "TYPE", "DESTPORT", "MACDA", "EGR-NICKNAME", "IGR-NICKNAME");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "--------------------------------------------------------------------------------\n");
        break;

    case SYS_NH_TYPE_RSPAN:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "Rspan Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s%s\n", "NHID", "TYPE", "VLAN");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "------------------------------------\n");
        break;

    case SYS_NH_TYPE_MISC:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "Misc Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s%-8s\n", "NHID", "TYPE","DESTPORT");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------\n");
        break;

    case SYS_NH_TYPE_WLAN_TUNNEL:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "Wlan Tunnel Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "\n%-8s%-15s%-15s%-11s%-11s%-18s%-18s%s\n",
                       "NHID", "TYPE", "TUNNEL_TYPE", "DESTPORT", "SRCPORT", "IPSA/IPDA", " ", "IS_DOT11");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "--------------------------------------------------------------------------------------------------------------------------------\n");
        break;
    case SYS_NH_TYPE_SRV6:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "\n%-8s%-15s%-11s%-8s%-8s%-12s%-12s%-12s\n",
                       "NHID", "TYPE", "DESTPORT", "VLAN", "L3IFID", "ARPID", "SRHID", "SID_NUM");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                       "------------------------------------------------------------------------------------\n");
        break;
    case SYS_NH_TYPE_OVERLAY:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s%-10s%-10s%-10s\n", "NHID", "OLVNI", "LDP", "ARPID", "ECMP-GRP");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------------------------\n");
        break;
    case SYS_NH_TYPE_APS:
        if (is_all)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-20s\n", "APS Nexthop:");
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-8s%-15s\n", "NHID", "TYPE");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------\n");
        break;
    case SYS_NH_TYPE_OVERLAY_VNI:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "Flags: H-hierarchy overlay   F-mapping new fid     S-strip svlan       C-strip cvlan\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "       V-cross vni           U-update macsa        L-logic port check  T-TTL no decrease\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "       R-layer3 overlay      B-bind logic port\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "---------------------------------------------------------------------------------------------------------\n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-12s%-15s%-15s%-20s%-20s%-20s%-20s\n", "NHID", "FLAG", "FID", "MACDA", "MACSA", "ETHER TYPE", "CID");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "---------------------------------------------------------------------------------------------------------\n");
        break;
    default:
        return;
    }

    return;
}

void
sys_usw_nh_dump_type(uint8 lchip, uint32 nhid, sys_usw_nh_type_t nh_type, uint8 detail)
{
    uint8 bind_type = SYS_NH_TYPE_NULL;

    switch (nh_type)
    {
    case SYS_NH_TYPE_MCAST:
        sys_usw_nh_dump_mcast(lchip, nhid, detail);
        break;

    case SYS_NH_TYPE_BRGUC:
        sys_usw_nh_dump_brguc(lchip, nhid, detail);
        break;

    case SYS_NH_TYPE_IPUC:
        sys_usw_nh_dump_ipuc(lchip, nhid, detail, &bind_type);
        break;

    case SYS_NH_TYPE_MPLS:
        sys_usw_nh_dump_mpls(lchip, nhid, detail, &bind_type);
        break;

    case SYS_NH_TYPE_ECMP:
        sys_usw_nh_dump_ecmp(lchip, nhid, detail);
        break;

    case SYS_NH_TYPE_DROP:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "NHID is %u, Drop Nexthop\n", nhid);
        break;

    case SYS_NH_TYPE_TOCPU:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "NHID is %u, ToCPU Nexthop\n", nhid);
        break;

    case SYS_NH_TYPE_UNROV:
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "NHID is %u, Unresolved Nexthop\n", nhid);
        break;

    case SYS_NH_TYPE_ILOOP:
        sys_usw_nh_dump_iloop(lchip, nhid, detail);
        break;

    case SYS_NH_TYPE_IP_TUNNEL:
        sys_usw_nh_dump_ip_tunnel(lchip, nhid, detail, &bind_type);
        break;
    case SYS_NH_TYPE_TRILL:
        sys_usw_nh_dump_trill(lchip, nhid, detail, &bind_type);
        break;

    case SYS_NH_TYPE_RSPAN:
        sys_usw_nh_dump_rspan(lchip, nhid, detail);
        break;

    case SYS_NH_TYPE_MISC:
        sys_usw_nh_dump_misc(lchip, nhid, detail, &bind_type);
        break;
    case SYS_NH_TYPE_WLAN_TUNNEL:
        sys_usw_nh_dump_wlan_tunnel(lchip, nhid, detail);
        break;
    case SYS_NH_TYPE_SRV6:
        sys_usw_nh_dump_srv6(lchip, nhid, detail, &bind_type);
        break;
    case SYS_NH_TYPE_OVERLAY:
        sys_usw_nh_dump_overlay(lchip, nhid, detail, &bind_type);
        break;
	case SYS_NH_TYPE_APS:
        sys_usw_nh_dump_aps(lchip, nhid, detail, &bind_type);
        break;
    case SYS_NH_TYPE_OVERLAY_VNI:
        sys_usw_nh_dump_overlay_vni(lchip, nhid, detail, &bind_type);
        break;
    default:
        return;
    }
    if (detail )
    {
        sys_usw_nh_dump_table_offset(lchip, nhid, bind_type);
    }

}


void
sys_usw_nh_dump_by_type(uint8 lchip, uint32 nhid, sys_usw_nh_type_t nh_type, uint8 detail)
{
    sys_usw_nh_dump_head_by_type(lchip, nhid, nh_type, 0);
    sys_usw_nh_dump_type(lchip, nhid, nh_type, detail);

    return;
}



int32
sys_usw_nh_dump(uint8 lchip, uint32 nhid, bool detail)
{
    sys_nh_info_com_t* p_nhinfo = NULL;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;
    CTC_ERROR_RETURN_WITH_UNLOCK(sys_usw_nh_get_nhinfo_by_nhid(lchip, nhid,  &p_nhinfo), p_usw_nh_api_master[lchip]->p_mutex);
    if (p_nhinfo == NULL)
    {
        SYS_NH_UNLOCK;
        return CTC_E_NOT_EXIST;
    }
    if(CTC_FLAG_ISSET(p_nhinfo->hdr.nh_entry_flags, SYS_NH_INFO_FLAG_IS_UNROV))
    {
       SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nNexthop is %u unresolved Nexthop\n", nhid);
    }
    sys_usw_nh_dump_by_type(lchip, nhid, p_nhinfo->hdr.nh_entry_type, detail);

    SYS_NH_UNLOCK;

    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_mcast_group(uint8 lchip, uint32 group_id, uint8 detail)
{
    uint32 nhid = 0;

    SYS_NH_INIT_CHECK;
    CTC_ERROR_RETURN(sys_usw_nh_get_mcast_nh(lchip, group_id, &nhid));
    CTC_ERROR_RETURN(sys_usw_nh_dump(lchip, nhid, detail));
    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_nhid_compare(sys_nh_info_com_t* p0, sys_nh_info_com_t* p1)
{
    return((p0->hdr.nh_id >= p1->hdr.nh_id)?1:(-1));
}

STATIC int32
_sys_usw_nh_dump_info(void* node_data, void* user_data)
{
    sys_nh_info_com_t* p_nhinfo = NULL;
    sys_traverse_t* p_dump_traverse = NULL;
    sys_usw_nh_type_t nh_type;
    ctc_linklist_t* p_tmp_list = NULL;
    uint8 dump_type = 0;

    p_dump_traverse = (sys_traverse_t*)user_data;
    p_nhinfo=(sys_nh_info_com_t*)node_data;
    nh_type = p_dump_traverse->value1;
    p_tmp_list = (ctc_linklist_t*)p_dump_traverse->data;
    dump_type = p_dump_traverse->value2;

    if ((SYS_NH_TYPE_MAX != nh_type) && (nh_type != p_nhinfo->hdr.nh_entry_type))
    {
        return CTC_E_NONE;
    }

    if (((dump_type == 1) && (p_nhinfo->hdr.nh_id < SYS_NH_INTERNAL_NHID_BASE)) ||
       ((dump_type == 2) && (p_nhinfo->hdr.nh_id >= SYS_NH_INTERNAL_NHID_BASE)))
    {
        return CTC_E_NONE;
    }

    ctc_listnode_add_sort(p_tmp_list, p_nhinfo);

    return CTC_E_NONE;
}

/*dump_type:0-All, 1-Internal Onlt, 2-Externel Only*/
int32
sys_usw_nh_dump_all(uint8 lchip, sys_usw_nh_type_t nh_type, uint8 dump_type)
{
    uint32 start_type = 0;
    uint32 end_type = 0;
    uint32 loop = 0;
    sys_traverse_t dump_traverse;
    ctc_linklist_t* p_tmp_list = NULL;
    sys_nh_info_com_t* p_nhinfo = NULL;
    struct ctc_listnode* node;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;

    p_tmp_list = ctc_list_create((ctc_list_cmp_cb_t) _sys_usw_nh_nhid_compare, NULL);

    if(!p_tmp_list)
    {
        SYS_NH_UNLOCK;
        return CTC_E_NO_MEMORY;
    }

    start_type = (SYS_NH_TYPE_MAX == nh_type) ? SYS_NH_TYPE_NULL : nh_type;
    end_type   = (SYS_NH_TYPE_MAX == nh_type) ? (SYS_NH_TYPE_MAX - 1) : nh_type;

    for (loop = start_type; loop <= end_type; loop++)
    {
        sal_memset(&dump_traverse, 0, sizeof(dump_traverse));
        dump_traverse.data = p_tmp_list;
        dump_traverse.value1 = loop;
        dump_traverse.value2 = dump_type;

        ctc_hash_traverse(g_usw_nh_master[lchip]->nhid_hash, (hash_traversal_fn)_sys_usw_nh_dump_info, &dump_traverse);

        if (p_tmp_list->count)
        {
            p_nhinfo = (sys_nh_info_com_t*)p_tmp_list->head->data;
            sys_usw_nh_dump_head_by_type(lchip, p_nhinfo->hdr.nh_id,loop, ((SYS_NH_TYPE_MAX == nh_type)?1:0));
        }

        CTC_LIST_LOOP(p_tmp_list, p_nhinfo, node)
        {
            sys_usw_nh_dump_type(lchip, p_nhinfo->hdr.nh_id, p_nhinfo->hdr.nh_entry_type, FALSE);
        }

        if (p_tmp_list->count)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");
        }

        ctc_list_delete_all_node(p_tmp_list);

    }


    ctc_list_free(p_tmp_list);
    SYS_NH_UNLOCK;
    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_dump_arp(uint8 lchip, sys_nh_db_arp_t* p_arp, uint8 detail)
{
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12d%-12s",
                   p_arp->arp_id,     (CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_DROP) ? "Discard" :
                            ((CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_FLAG_REDIRECT_TO_CPU)) ? "TO CPU" : "FWD")));

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%04x.%04x.%04x  ",
                            (p_arp->mac_da[0] << 8 | p_arp->mac_da[1]), (p_arp->mac_da[2] << 8 | p_arp->mac_da[3]),(p_arp->mac_da[4] << 8 | p_arp->mac_da[5]));
    if(CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_VLAN_VALID))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12d", p_arp->output_vid);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", "-");
    }
    
    if(CTC_FLAG_ISSET(p_arp->flag, SYS_NH_ARP_CVLAN_VALID))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12d", p_arp->output_cvid);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s", "-");
    }


    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "0x%.4x      ",  (p_arp->gport));
    if(p_arp->l3if_id)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12d \n", p_arp->l3if_id);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s \n","-");
    }
    if (1 == detail)
    {
        if (p_arp->offset || p_arp->offset_dyn|| p_arp->destmap_profile || p_arp->ref_cnt)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "------------------------------------------------\n");
        }

        if (p_arp->offset)
        {
            _sys_usw_nh_dump_l2edit_outer(lchip, p_arp->offset);
        }

        if (p_arp->offset_dyn)
        {
            if (p_arp->is_8w)
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n",  DRV_FROM_TMM(lchip)? "DsL2EditAddEth2X" : "DsL2EditEth6W", p_arp->offset_dyn);
            }
            else
            {
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n",  DRV_FROM_TMM(lchip)? "DsL2EditAddEth1X" : "DsL2EditEth3W", p_arp->offset_dyn);
            }
        }

        if (p_arp->ldp_mac_profile)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "DsEgressPortMac", p_arp->ldp_mac_profile);
        }

        if (p_arp->destmap_profile)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "DsDestMapProfileUc", p_arp->destmap_profile);
        }

        if (p_arp->ref_cnt)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "Ref Count", p_arp->ref_cnt);
        }

        if (p_arp->pd->nh_list && p_arp->pd->nh_list->count)
        {
            sys_nh_db_arp_nh_node_t* p_arp_nh_node = NULL;
            ctc_list_pointer_node_t* node = NULL;

            CTC_LIST_POINTER_LOOP(node, p_arp->pd->nh_list)
            {
                p_arp_nh_node = _ctc_container_of(node, sys_nh_db_arp_nh_node_t, head);
                SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-20s :%u \n", "ipuc nhid", p_arp_nh_node->nhid);
            }
        }

    }

    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_arp_traverse(sys_nh_db_arp_t* p_arp, void* user_data)
{
    uint8 lchip = 0;
    sys_traverse_t* traversal_data = (sys_traverse_t *)user_data;
    lchip = traversal_data->value1;
    _sys_usw_nh_dump_arp(lchip, p_arp,  0);
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_arp(uint8 lchip, uint32 arp_id, uint8 detail, uint8 all)
{
    sys_nh_db_arp_t* p_arp = NULL;
    int32 ret = CTC_E_NONE;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;

    if (0 == all)
    {
        p_arp = (sys_usw_nh_lkup_arp_id(lchip, arp_id));
        if (!p_arp)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% ARP Id is not exist \n");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, " Entry not exist \n");
            ret = CTC_E_NOT_EXIST;
            goto error_proc;
        }
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s%-12s%-16s%-12s%-12s%-12s%-12s", "ARP_ID", "ACTION", "MAC_DA", "VLAN", "CVLAN", "PORT", "L3IF");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n----------------------------------------------------------------------------------\n");

    if (0 == all)
    {
        _sys_usw_nh_dump_arp(lchip, p_arp,  detail);
    }
    else
    {
        sys_traverse_t user_data;
        sal_memset(&user_data, 0 , sizeof(sys_traverse_t));
        user_data.value1 = lchip;
        ctc_hash_traverse(g_usw_nh_master[lchip]->arp_id_hash, (hash_traversal_fn)_sys_usw_nh_arp_traverse, (void *)&user_data);
    }

error_proc:
    SYS_NH_UNLOCK;
    return ret;
}

STATIC int32
_sys_usw_nh_dump_fp(uint8 lchip, sys_nh_fp_db_t* p_fp_db, uint8 detail)
{
    DsL3EditRwFlex_m l3edit;
    uint8 l3_edit_type = 0;
    uint8 i = 0;
    char *str[] = {"INS", "DEL", "REP"};
    uint32 tbl_id = 0;
    uint32 tbl_id_pair = 0;
    uint8 fp2 = DRV_FROM_AT(lchip) && p_fp_db->fp2;
    uint32 entry_type = fp2? SYS_NH_ENTRY_TYPE_XFP_EDIT : SYS_NH_ENTRY_TYPE_L3EDIT_FP + SYS_NH_TYPE_STEP_TO_INNER;

    sal_memset(&l3edit, 0, sizeof(l3edit));

    if (DRV_FROM_AT(lchip) && (SYS_NH_FP_INST_PAIR_EXT == p_fp_db->ext_mode))
    {
        entry_type = SYS_NH_ENTRY_TYPE_L3EDIT_FP;
    }

    CTC_ERROR_RETURN(sys_usw_nh_get_asic_table(lchip, entry_type, p_fp_db->l3_edit_ptr, &l3edit));

    l3_edit_type = GetDsL3EditRwFlex(V, l3EditType_f, &l3edit);

    if (l3_edit_type == DRV_ENUM(DRV_L3EDITTYPE_INSFLEX) || l3_edit_type == DRV_ENUM(DRV_L3EDITTYPE_INSFLEX8X))
    {
        i = 0;
        tbl_id = fp2? DsXEditInsFlex_t : (DRV_FROM_AT(lchip)? DsL3EditInsFlex0_t : DsL3EditInsFlex_t);
        tbl_id_pair = DsL3EditInsFlex_t;
    }
    else if(l3_edit_type == DRV_ENUM(DRV_L3EDITTYPE_DELFLEX))
    {
        i = 1;
        tbl_id = fp2? DsXEditDelFlex_t : (DRV_FROM_AT(lchip)? DsL3EditDelFlex0_t : DsL3EditDelFlex_t);
        tbl_id_pair = DsL3EditDelFlex_t;
    }
    else if(l3_edit_type == DRV_ENUM(DRV_L3EDITTYPE_RWFLEX))
    {
        i = 2;
        tbl_id = fp2? DsXEditRwFlex_t : (DRV_FROM_AT(lchip)? DsL3EditRwFlex0_t : DsL3EditRwFlex_t);
        tbl_id_pair = DsL3EditRwFlex_t;
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10u %-10s %-10s\n",  p_fp_db->fp_id,  str[i], fp2? "Y" : "N");


    if (1 == detail)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "------------------------------------------------\n");

        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           DRV_TABLE_NAME(lchip, tbl_id), p_fp_db->l3_edit_ptr);

        if (p_fp_db->pair_edit_ptr)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           DRV_TABLE_NAME(lchip, tbl_id_pair), p_fp_db->pair_edit_ptr);
        }

        if (p_fp_db->p_alu_prof)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           fp2? "DsXEditFlexAluProfile":"DsL3EditFlexAluProfile", p_fp_db->p_alu_prof->profile_id);
        }

        if (p_fp_db->p_data_prof)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           fp2?"DsXEditInsertHeaderTemplate":"DsFlexEditInsertHeaderTemplate", p_fp_db->p_data_prof->profile_id);
        }

        if (p_fp_db->p_l3chksum_prof)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           "DsPktRwL3ChkSumMaskProfile", p_fp_db->p_l3chksum_prof->profile_id);
        }

        if (p_fp_db->p_l4chksum_prof)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           "DsPktRwL4ChkSumMaskProfile", p_fp_db->p_l4chksum_prof->profile_id);
        }

    }
    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_fp_traverse(sys_nh_fp_db_t* p_fp, void* user_data)
{
    uint8 lchip = 0;
    sys_traverse_t* traversal_data = (sys_traverse_t *)user_data;
    lchip = traversal_data->value1;
    _sys_usw_nh_dump_fp(lchip, p_fp,  0);
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_fp(uint8 lchip, uint32 fp_id, uint8 detail, uint8 all)
{
    sys_nh_fp_db_t* p_fp_db = NULL;
    sys_nh_fp_db_t tmp_fp_db;
    int32 ret = CTC_E_NONE;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;
    if (0 == all)
    {
        sal_memset(&tmp_fp_db, 0, sizeof(tmp_fp_db));
        tmp_fp_db.fp_id = fp_id;
        p_fp_db = ctc_hash_lookup(g_usw_nh_master[lchip]->fp_id_hash, &tmp_fp_db);
        if (NULL == p_fp_db)
        {
            ret = CTC_E_ENTRY_NOT_EXIST;
            goto error_proc;
        }
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10s %-10s %-10s\n", "FP-ID","ACTION", "STAGE2_FP");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "---------------------------------------------------------\n");

    if (0 == all)
    {
        _sys_usw_nh_dump_fp(lchip, p_fp_db,  detail);
    }
    else
    {
        sys_traverse_t user_data;
        sal_memset(&user_data, 0 , sizeof(sys_traverse_t));
        user_data.value1 = lchip;
        ctc_hash_traverse(g_usw_nh_master[lchip]->fp_id_hash, (hash_traversal_fn)_sys_usw_nh_fp_traverse, (void *)&user_data);
    }

error_proc:
    SYS_NH_UNLOCK;
    return ret;
}

STATIC int32
_sys_usw_nh_dump_srh(uint8 lchip, sys_nh_db_srh_t* p_srh,  uint8 detail)
{
    char sid[200] = {0};
    uint8 i = 0;
    ds0_t ds;
    uint32 cmd = 0;
    ipv6_addr_t sid_list[SYS_NEXTHOP_SRV6_SR_NUM];
    ipv6_addr_t sw_ipv6_address;
    uint32 ref_cnt = 0;
    sys_nh_ref_list_node_t* p_curr = NULL;

    if (CTC_FLAG_ISSET(p_srh->flag, SYS_NH_SRH_FLAG_APS))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12u%-10s%-10s%-10s%-10s%s\n", p_srh->srh_id, "APS", "-", "-", "-", "-");
        return CTC_E_NONE;
    }


    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12u%-10u%-10d%-10s%-10s", p_srh->srh_id, p_srh->arp_id, p_srh->num, p_srh->is_reduce?"YES":"NO",
                    CTC_FLAG_ISSET(p_srh->flag, SYS_NH_SRH_FLAG_DENY_REPLACE_IPDA)?"NO":"YES");
    cmd = DRV_IOR(DsL3EditAddIp6ExtHeader_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, p_srh->l3edit_ptr, cmd, &ds));
    GetDsL3EditAddIp6ExtHeader(A, segment0_f, &ds, sid_list[0]);
    GetDsL3EditAddIp6ExtHeader(A, segment1_f, &ds, sid_list[1]);
    GetDsL3EditAddIp6ExtHeader(A, segment2_f, &ds, sid_list[2]);
    for (i = 0; i < p_srh->num; i++)
    {
        sw_ipv6_address[0] = sal_ntohl(sid_list[i][3]);
        sw_ipv6_address[1] = sal_ntohl(sid_list[i][2]);
        sw_ipv6_address[2] = sal_ntohl(sid_list[i][1]);
        sw_ipv6_address[3] = sal_ntohl(sid_list[i][0]);
        sal_inet_ntop(AF_INET6, sw_ipv6_address, sid, CTC_IPV6_ADDR_STR_LEN);
        if (0 == i)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-18s\n",  sid);
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%52s%-18s\n", " ", sid);
        }
    }
    if (!p_srh->num)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n");
    }

    if (0 == detail)
    {
        return CTC_E_NONE;
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------------------\n");
    if (p_srh->l3edit_ptr)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                       "DsL3EditAddIp6ExtHeader", p_srh->l3edit_ptr);
    }

    p_curr = p_srh->pd->nh_list;
    while (p_curr)
    {
        ref_cnt++;
        p_curr = p_curr->p_next;
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n", "Ref Count", ref_cnt);

    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_srh_traverse(sys_nh_db_srh_t* p_srh, void* user_data)
{
    uint8 lchip = 0;
    sys_traverse_t* traversal_data = (sys_traverse_t *)user_data;
    lchip = traversal_data->value1;
    _sys_usw_nh_dump_srh(lchip, p_srh,  0);
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_srh(uint8 lchip, uint32 srh_id, uint8 detail, uint8 all)
{
    sys_nh_db_srh_t* p_srh = NULL;
    sys_nh_db_srh_t srh_db;
    int32 ret = CTC_E_NONE;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;
    if (0 == all)
    {
        sal_memset(&srh_db, 0, sizeof(sys_nh_db_srh_t));
        srh_db.srh_id = srh_id;
        p_srh = ctc_hash_lookup(g_usw_nh_master[lchip]->srh_id_hash, &srh_db);
        if (!p_srh)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% SRH Id is not exist \n");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, " Entry not exist \n");
            ret = CTC_E_NOT_EXIST;
            goto error_proc;
        }

        if (CTC_FLAG_ISSET(p_srh->flag, SYS_NH_SRH_FLAG_APS))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s%-10s%-15s%-15s\n", "SRH_ID", "APS_GRP", "W_PATH", "P_PATH");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "------------------------------------------------\n");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12d%-10d%-15d%-15d\n", srh_id, p_srh->arp_id, p_srh->l3edit_ptr, p_srh->p_srh_id);
            goto error_proc;
        }
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-12s%-10s%-10s%-10s%-10s%-10s\n", "SRH_ID", "ARP_ID", "SID_NUM", "REDUCE", "REP_IPDA","SID");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "---------------------------------------------------------------------------------------------\n");

    if (0 == all)
    {
        _sys_usw_nh_dump_srh(lchip, p_srh,  detail);
    }
    else
    {
        sys_traverse_t user_data;
        sal_memset(&user_data, 0 , sizeof(sys_traverse_t));
        user_data.value1 = lchip;
        ctc_hash_traverse(g_usw_nh_master[lchip]->srh_id_hash, (hash_traversal_fn)_sys_usw_nh_srh_traverse, (void *)&user_data);
    }

error_proc:
    SYS_NH_UNLOCK;
    return ret;
}

STATIC int32
_sys_usw_nh_dump_ol_tunnel(uint8 lchip, sys_nh_db_ol_tunnel_t* p_ldp, uint8 detail)
{

    if (CTC_FLAG_ISSET(p_ldp->flag, SYS_NH_OL_TUNNEL_REROUTE))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10d%-10s%-10s0x%04x    %-10s\n", p_ldp->logic_port, "-", "Y", p_ldp->gport, "-");
    }
    else if(p_ldp->tunnel_type == CTC_NH_OL_TUNNEL_TYPE_NONE)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10d%-10s%-10s0x%04x    %-10s\n", p_ldp->logic_port, "-", "N", p_ldp->gport,"-");
    }
    else
    {
        if (p_ldp->ul_nh_en)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10d%-10d%-10s%-10s%-10d\n", p_ldp->logic_port, p_ldp->arp_id, "N", "-", p_ldp->ul_nhid);
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10d%-10d%-10s%-10s%-10d\n", p_ldp->logic_port, p_ldp->arp_id, "N", "-", 0);
        }
    }

    if (0 == detail)
    {
        return CTC_E_NONE;
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------------------\n");
    if (p_ldp->dsl3edit_offset)
    {
        if (CTC_FLAG_ISSET(p_ldp->flag, SYS_NH_OL_TUNNEL_FLAG_IN_V4))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           p_ldp->is_4x ? "DsL3EditAddIp44X" : "DsL3EditAddIp4", p_ldp->dsl3edit_offset);
        }
        else
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n",
                           "DsL3EditAddIp6", p_ldp->dsl3edit_offset);
        }
    }

    if (DRV_FROM_AT(lchip))
    {
        if (SYS_NH_OVERLAY_NEW_MODE(lchip))
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n", "DsIngressLogicDestPort", p_ldp->logic_port);
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u \n", "DsEgressLogicDestPort", p_ldp->logic_port);
        if (CTC_FLAG_ISSET(p_ldp->flag, SYS_NH_OL_TUNNEL_FLAG_DSFWD) && p_ldp->ul_nh_en == 0)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " --%-32s :%u %s\n", "DsFwdHalf1", p_ldp->ul_nhid, "[3w]");
        }
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_dump_nsh(uint8 lchip, sys_nh_db_nsh_t* p_nsh,  uint8 detail)
{
    uint32 cmd = 0;
    uint32 stats_id = 0;
    uint8  temp_ch[CTC_NH_NSH_CH_LEN];
    DsNshEdit_m nsh_edit;
    EpeNextHopCtl_m epe_nh_ctl;
    uint32 stats_ptr = 0;
    uint32 tbl_id = 0;

    SYS_NH_NSH_EDIT_TBL(lchip, tbl_id);
    cmd = DRV_IOR(tbl_id, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, p_nsh->edit_offset, cmd, &nsh_edit));
    stats_ptr = GetDsNshEdit(V, statsPtr_f, &nsh_edit);
    if (stats_ptr)
    {
        cmd = DRV_IOR(EpeNextHopCtl_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip,0,cmd,&epe_nh_ctl));
        stats_ptr += GetEpeNextHopCtl(V, nshEditStatsBase_f, &epe_nh_ctl);
        sys_usw_flow_stats_lookup_statsid(lchip, CTC_STATS_STATSID_TYPE_NSH, stats_ptr, &stats_id, CTC_EGRESS);
    }

    if (p_nsh->ch)
    {
        sal_memcpy(temp_ch, p_nsh->ch, CTC_NH_NSH_CH_LEN);
    }
    else
    {
        sal_memset(temp_ch, 0, CTC_NH_NSH_CH_LEN);
    }
    if (!GetDsNshEdit(V, nshOperationType_f, &nsh_edit))
    {
        temp_ch[15] = GetDsNshEdit(V, nshBhNextProtocol_f, &nsh_edit);
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10u  %-8u  %-3u  %02hhX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX",
                p_nsh->nsh_id, GetDsNshEdit(V, nshSphSpi_f, &nsh_edit), GetDsNshEdit(V, nshSphSi_f, &nsh_edit),
                temp_ch[0], temp_ch[1], temp_ch[2], temp_ch[3],
                temp_ch[4], temp_ch[5], temp_ch[6], temp_ch[7]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX  %-3u  %-10u\n",
                temp_ch[8], temp_ch[9], temp_ch[10], temp_ch[11],
                temp_ch[12], temp_ch[13], temp_ch[14], temp_ch[15],
                GetDsNshEdit(V, nshBhTtl_f, &nsh_edit), stats_id);

    if (0 == detail)
    {
        return CTC_E_NONE;
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\nDetail Table offset \n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "-------------------------------------------\n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " -- %s                    : %-5u\n", DRV_TABLE_NAME(lchip, tbl_id), p_nsh->edit_offset);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "  -- Edit Offset                  : %-5u\n", SYS_NH_NSH_EDIT_OFFSET_UNMAP(p_nsh->edit_offset));
    if (p_nsh->ch)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, " -- DsNshEditContextHeaderProfile : %-5u\n\n", p_nsh->ch->index.index);
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_usw_nh_nsh_traverse(sys_nh_db_nsh_t* p_nsh, void* user_data)
{
    uint8 lchip = 0;
    sys_traverse_t* traversal_data = (sys_traverse_t *)user_data;
    lchip = traversal_data->value1;
    return _sys_usw_nh_dump_nsh(lchip, p_nsh, 0);
}

int32
sys_usw_nh_dump_nsh(uint8 lchip, uint32 nsh_id, uint8 detail, uint8 all)
{
    sys_nh_db_nsh_t* p_nsh = NULL;
    sys_nh_db_nsh_t nsh_db;
    int32 ret = CTC_E_NONE;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;
    if (0 == all)
    {
        sal_memset(&nsh_db, 0, sizeof(sys_nh_db_nsh_t));
        nsh_db.nsh_id = nsh_id;
        p_nsh = ctc_hash_lookup(g_usw_nh_master[lchip]->nsh, &nsh_db);
        if (!p_nsh)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%% NSH Id is not exist \n");
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, " Entry not exist \n");
            ret = CTC_E_NOT_EXIST;
            goto error_proc;
        }
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP,
                    "\nNSH_ID      SPI       SI   Context_Header                    TTL  STATS_ID\n"\
                    "----------------------------------------------------------------------------\n");

    if (0 == all)
    {
        _sys_usw_nh_dump_nsh(lchip, p_nsh, detail);
    }
    else
    {
        sys_traverse_t user_data;
        sal_memset(&user_data, 0 , sizeof(sys_traverse_t));
        user_data.value1 = lchip;
        ctc_hash_traverse(g_usw_nh_master[lchip]->nsh, (hash_traversal_fn)_sys_usw_nh_nsh_traverse, (void *)&user_data);
    }

error_proc:
    SYS_NH_UNLOCK;
    return ret;
}

STATIC int32
_sys_usw_nh_ol_tunnel_traverse(sys_nh_db_ol_tunnel_t* p_ldp, void* user_data)
{
    uint8 lchip = 0;
    sys_traverse_t* traversal_data = (sys_traverse_t *)user_data;
    lchip = traversal_data->value1;
    _sys_usw_nh_dump_ol_tunnel(lchip, p_ldp,  0);
    return CTC_E_NONE;
}

int32
sys_usw_nh_dump_overlay_tunnel(uint8 lchip, uint16 logic_dest_port, uint8 detail, uint8 all)
{
    sys_nh_db_ol_tunnel_t* p_ldp = NULL;
    sys_nh_db_ol_tunnel_t lpd_db;
    int32 ret = CTC_E_NONE;

    SYS_NH_INIT_CHECK;
    SYS_NH_LOCK;
    if (0 == all)
    {
        sal_memset(&lpd_db, 0, sizeof(lpd_db));
        lpd_db.logic_port = logic_dest_port;
        p_ldp = ctc_hash_lookup(g_usw_nh_master[lchip]->ol_tunnel_hash, &lpd_db);
        if (NULL == p_ldp)
        {
            SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_ERROR, " [Nexthop] overlay tunnel not exist!\n");
            ret = CTC_E_NOT_EXIST;
            goto error_proc;
        }
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-10s%-10s%-10s%-10s%-10s\n", "LDP", "ARP_ID", "RE_ROUTE", "GPORT", "UL_NH");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "------------------------------------------------------------\n");

    if (0 == all)
    {
        _sys_usw_nh_dump_ol_tunnel(lchip, p_ldp,  detail);
    }
    else
    {
        sys_traverse_t user_data;
        sal_memset(&user_data, 0 , sizeof(sys_traverse_t));
        user_data.value1 = lchip;
        ctc_hash_traverse(g_usw_nh_master[lchip]->ol_tunnel_hash, (hash_traversal_fn)_sys_usw_nh_ol_tunnel_traverse, (void *)&user_data);
    }
error_proc:
    SYS_NH_UNLOCK;
    return ret;
}
int32
sys_usw_nh_dump_resource_usage(uint8 lchip)
{
    uint32 used_cnt = 0;
    uint32 entry_enum, glb_entry_num;
    uint8 dyn_tbl_idx ;
    uint8 idx = 0;
    sys_usw_nh_master_t* p_nh_master = NULL;
    #define NHTBL_CNT p_nh_master->nhtbl_used_cnt
    uint32 entry_enum1 = 0;
    char* edit_mode[] = {"Ingress", "User Define", "Misc"};

    SYS_NH_INIT_CHECK;
    p_nh_master = g_usw_nh_master[lchip];
    SYS_NH_LOCK;
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "--------------------------Work Mode-----------------------------------\n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %s\n", "Packet Edit mode", edit_mode[p_nh_master->pkt_nh_edit_mode]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %s\n","Mpls SPME Disable", p_nh_master->mpls_spme_dis ?"Yes":"No");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %d\n", "Max ecmp member",p_nh_master->max_ecmp);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %d\n", "ECMP group count",p_nh_master->cur_ecmp_cnt);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %s\n", "Logic replication",p_nh_master->ipmc_logic_replication ? "Yes":"No");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: 0x%x\n", "Internal Nexthop Base", (p_nh_master->internal_nexthop_base<<4));
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %d\n", "Met mode",p_nh_master->met_mode);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %d\n", "Hecmp",p_nh_master->h_ecmp_en);
    if (DRV_FROM_AT(lchip))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %d\n", "Met extension mode", p_nh_master->met_ext_mode);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %d\n", "NH Xlate Base", p_nh_master->nh_mapper_base);
    }

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n--------------------------Nexthop Resource----------------------------\n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s\n","External Nexthop ");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Total count ",p_nh_master->max_external_nhid - 1);/*nhid 0: reserved*/
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Used count", (p_nh_master->nhid_hash->count-p_nh_master->internal_nh_used_num));
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s\n","Internal Nexthop");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Total count", SYS_NH_INTERNAL_NHID_MAX_SIZE);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Used  count ",p_nh_master->internal_nh_used_num);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s:\n","MPLS Tunnel");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Total count ",p_nh_master->max_tunnel_id);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Used  count ",p_nh_master->tunnel_id_vec->used_cnt);

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n--------------------------Created Nexthop-----------------------------\n");
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","Mcast Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_MCAST]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","BRGUC Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_BRGUC]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","IPUC Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_IPUC]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","MPLS Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_MPLS]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","ECMP Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_ECMP]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","Rspan Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_RSPAN]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","Ip Tunnel Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_IP_TUNNEL]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","TRILL Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_TRILL]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","Wlan Tunnel Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_WLAN_TUNNEL]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","SRv6 Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_SRV6]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","Overlay Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_OVERLAY]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","Misc Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_MISC]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","ToCpu Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_TOCPU]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","unRov Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_UNROV]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","ILoop Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_ILOOP]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","ELoop Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_ELOOP]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","APS Nexthop", p_nh_master->nhid_used_cnt[SYS_NH_TYPE_APS]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","Rsv Drop Nexthop", 1);


    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n--------------------------Nexthop Table from Profile------------------\n");
    sys_usw_ftm_get_dynamic_table_info(lchip, DsFwd_t,  &dyn_tbl_idx, &entry_enum, &glb_entry_num, NULL);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in DYN%d_SRAM, opf type%d idx%d\n", "DsFwd",
           entry_enum, dyn_tbl_idx, g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_FWD].opf_pool_type);
    if (DRV_FROM_AT(lchip))
    {
        sys_usw_ftm_get_dynamic_table_info(lchip, DsFwd1_t,  &dyn_tbl_idx, &entry_enum, &glb_entry_num, NULL);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in DYN%d_SRAM, opf type%d idx%d\n", "DsFwd1",
            entry_enum, dyn_tbl_idx, g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_FWD1].opf_pool_type);
    }
    sys_usw_ftm_get_dynamic_table_info(lchip, DRV_FROM_AT(lchip)? DsMetVector1X_t : DsMetEntry3W_t,  &dyn_tbl_idx,  &entry_enum, &glb_entry_num, NULL);
    if (DRV_FROM_AT(lchip))
    {
        uint32 entry_num1 = 0;
        CTC_ERROR_RETURN(sys_usw_ftm_query_table_entry_num(lchip, DsMetEntrySlim1X_t, &entry_num1));
        entry_enum += entry_num1;
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in DYN%d_SRAM, opf type%d idx%d\n", "DsMet",
        entry_enum, dyn_tbl_idx, g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_MET].opf_pool_type);
    sys_usw_ftm_get_dynamic_table_info(lchip, DsNextHop4W_t,  &dyn_tbl_idx, &entry_enum, &glb_entry_num, NULL);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in DYN%d_SRAM, opf type%d idx%d\n", "DsNexthop", entry_enum, dyn_tbl_idx,
        g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_NEXTHOP_4W].opf_pool_type);
    if (DRV_FROM_AT(lchip))
    {
        sys_usw_ftm_get_dynamic_table_info(lchip, DsL3EditAddMpls1X0_t,  &dyn_tbl_idx, &entry_enum, &glb_entry_num, NULL);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in DYN%d_SRAM, opf type%d idx%d\n", "DsEditInner",
            entry_enum, dyn_tbl_idx, g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_L3EDIT_INNER_FROM].opf_pool_type);
    }
    sys_usw_ftm_get_dynamic_table_info(lchip, (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))? DsL3EditMpls3W_t : DsL3EditAddMpls1X_t,  &dyn_tbl_idx, &entry_enum, &glb_entry_num, NULL);

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in DYN%d_SRAM, opf type%d idx%d\n", "DsEdit", entry_enum, dyn_tbl_idx,
        g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS].opf_pool_type);
    entry_enum1 = DRV_TABLE_MAX_INDEX(lchip, DsL3Edit6W3rd_t)*2;
    entry_enum = DRV_TABLE_MAX_INDEX(lchip, DsL2Edit6WOuter_t)*2;
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in STATIC_SRAM, opf type%d idx%d\n", "DsL3Edit3W_SPME", entry_enum1,
        g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_L3EDIT_SPME].opf_pool_type);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u in STATIC_SRAM, opf type%d idx%d\n", "DsL2EditEth_Outer", entry_enum,
        g_usw_nh_master[lchip]->nh_opf_type, p_nh_master->nh_table_info_array[SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_4W].opf_pool_type);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n--------------------[lchip :%d]Nexthop Table Usage --------------------\n",lchip);


    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n--------------------------Nexthop Table Usage-------------------------\n");

    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "DsFwd", NHTBL_CNT[SYS_NH_ENTRY_TYPE_FWD] + NHTBL_CNT[SYS_NH_ENTRY_TYPE_FWD_HALF]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "DsFwd1", NHTBL_CNT[SYS_NH_ENTRY_TYPE_FWD1] + NHTBL_CNT[SYS_NH_ENTRY_TYPE_FWD_HALF1]);

    used_cnt = NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET]
             + NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET_6W]
             + NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET_12W]
             + NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET_RSVED]
             + p_nh_master->max_glb_met_offset;
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n", "DsMet", used_cnt);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u \n", "--Global DsMet", p_nh_master->max_glb_met_offset);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "--Local DsMet3w(1X, MCAST)",  NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "--Local DsMet3w(1X, STK)",  NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET_RSVED]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "--Local DsMet6w(2X)", NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET_6W]);
    if (DRV_FROM_AT(lchip))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "--Local DsMet12w(4X)", NHTBL_CNT[SYS_NH_ENTRY_TYPE_MET_12W]);
    }

    used_cnt = NHTBL_CNT[SYS_NH_ENTRY_TYPE_NEXTHOP_4W]
             + NHTBL_CNT[SYS_NH_ENTRY_TYPE_NEXTHOP_8W]
             + p_nh_master->max_glb_nh_offset;
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n","DsNexthop",used_cnt);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Global DsNexthop",p_nh_master->max_glb_nh_offset);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Local DsNextHop4W",
        NHTBL_CNT[SYS_NH_ENTRY_TYPE_NEXTHOP_4W] );
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--Local DsNextHop8W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_NEXTHOP_8W]);

#if defined(ARCTIC)
    if(DRV_FROM_AT(lchip))
    {
        used_cnt = 0;
        for (idx = SYS_NH_ENTRY_TYPE_L2EDIT_INNER_FROM; idx <= SYS_NH_ENTRY_TYPE_L2EDIT_INNER_TO; idx++)
        {
            used_cnt += NHTBL_CNT[idx];
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n","DsL2Edit(Inner)",used_cnt);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditAddEth1X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_3W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditAddEth2X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_6W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditAddRaw0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_FLEX_8W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditLoopback0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_LPBK + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditAutoEth1X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_3W_RW + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditAutoEth2X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_6W_RW + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditRwEth1X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_SWAP + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditRwEth2X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_SWAP + SYS_NH_TYPE_STEP_TO_INNER]
                                                                                    + NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_OF_6W + SYS_NH_TYPE_STEP_TO_INNER]);

        used_cnt = 0;
        for (idx = SYS_NH_ENTRY_TYPE_L3EDIT_INNER_FROM; idx <= SYS_NH_ENTRY_TYPE_L3EDIT_INNER_TO; idx++)
        {
            used_cnt += NHTBL_CNT[idx];
        }
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n","DsL3Edit(Inner)",used_cnt);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddRaw0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_FLEX + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddMpls1X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddMpls2X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS_2X + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddMpls4X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS_12W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp40",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V4 + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddIp44X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V4_4X + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp60",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V6 + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp41X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_4W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditRwIp40",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_8W + SYS_NH_TYPE_STEP_TO_INNER]
                                                                                 + NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_OF_6W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp62X0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_V6_8W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp60",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_OF_12W + SYS_NH_TYPE_STEP_TO_INNER]
                                                                                 + NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_V6_16W + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp6Sr",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_ADD_SRV6 + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp6Sr",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_RW_SRV6 + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp6ExtHeader",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_SRH + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddTrill0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TRILL + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditRwFlex0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_FP + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditLoopback0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_LPBK + SYS_NH_TYPE_STEP_TO_INNER]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u\n","--DsL3EditAddRaw0",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_ADD_RAW + SYS_NH_TYPE_STEP_TO_INNER]);
    }
#endif

    used_cnt = 0;
    for (idx = SYS_NH_ENTRY_TYPE_L2EDIT_FROM; idx <= SYS_NH_ENTRY_TYPE_L2EDIT_TO; idx++)
    {
        used_cnt += NHTBL_CNT[idx];
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n", DRV_FROM_AT(lchip)? "DsL2Edit(Outer)" : "DsL2Edit", used_cnt);
    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditEth3W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_3W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditEth6W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_6W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditFlex8W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_FLEX_8W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditLoopback",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_LPBK]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditSwap",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_SWAP]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditInnerSwap",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_SWAP]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u\n","--DsL2EditOf",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_OF_6W]);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditAddEth1X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_3W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditAddEth2X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_6W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditAddRaw",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_FLEX_8W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditLoopback",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_LPBK]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditAutoEth1X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_3W_RW]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditAutoEth2X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_6W_RW]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL2EditRwEth1X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_INNER_SWAP]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL2EditRwEth2X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_SWAP]
                                                                                    + NHTBL_CNT[SYS_NH_ENTRY_TYPE_L2EDIT_OF_6W]);
    }

    used_cnt = 0;
    for (idx = SYS_NH_ENTRY_TYPE_L3EDIT_FROM; idx <= SYS_NH_ENTRY_TYPE_L3EDIT_TO; idx++)
    {
        used_cnt += NHTBL_CNT[idx];
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n", DRV_FROM_AT(lchip)? "DsL3Edit(Outer)" : "DsL3Edit", used_cnt);
    if (DRV_IS_DUET2(lchip) || DRV_IS_TSINGMA(lchip))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditFlex",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_FLEX]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditMpls",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditMpls12W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS_12W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditTunnelV4",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V4]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditTunnelV6",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V6]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditNat3W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_4W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditNat6W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_8W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditOF6W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_OF_6W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditOF12W",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_OF_12W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditTrill",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TRILL]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u\n","--DsL3EditLoopback",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_LPBK]);
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddRaw",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_FLEX]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddMpls1X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddMpls2X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS_2X]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddMpls4X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_MPLS_12W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp4",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V4]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddIp44X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V4_4X]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp6",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V6]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp41X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_4W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditRwIp4",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_8W]
                                                                                 + NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_OF_6W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp62X",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_V6_8W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp6",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_OF_12W]
                                                                                 + NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_NAT_V6_16W]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp6Sr",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_ADD_SRV6]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditRwIp6Sr",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_RW_SRV6]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditAddIp6ExtHeader",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_SRH]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditAddTrill",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TRILL]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u","--DsL3EditRwFlex",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_FP]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","--DsL3EditLoopback",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_LPBK]);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %-8u\n","--DsL3EditAddRaw",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_ADD_RAW]);
    }


    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "\n%-26s: %u\n","DsL3TunnelV4IpSa",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V4_IPSA]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","DsL3TunnelV6IpSa",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_TUNNEL_V6_IPSA]);
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","DsL3Edit3W_SPME",NHTBL_CNT[SYS_NH_ENTRY_TYPE_L3EDIT_SPME]);
    used_cnt = p_nh_master->nhtbl_used_cnt[SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_4W]
             + p_nh_master->nhtbl_used_cnt[SYS_NH_ENTRY_TYPE_L2EDIT_OUTER_8W];
    if (g_usw_nh_master[lchip]->mpls_spme_dis)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u%s\n","DsL2EditEth_Outer",used_cnt, " [DsL3Edit3W_SPME(>=2048)]");
    }
    else
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","DsL2EditEth_Outer",used_cnt);
    }
    if((DRV_IS_TMM(lchip) || DRV_IS_TMG(lchip)))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "DsQMsgReplicationList", NHTBL_CNT[SYS_NH_ENTRY_TYPE_LOGIC_REP]);
    }
    SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n","ARP",sys_usw_nh_get_arp_num(lchip));

    if (DRV_FROM_TMM(lchip))
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "SRH", p_nh_master->srh_id_hash->count);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "FP", p_nh_master->fp_id_hash->count);
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "Overlay Tunnel", p_nh_master->ol_tunnel_hash->count);
    }
    if (p_nh_master->nsh)
    {
        SYS_NH_DBG_OUT(CTC_DEBUG_LEVEL_DUMP, "%-26s: %u\n", "NSH", p_nh_master->nsh->count);
    }
    SYS_NH_UNLOCK;

    return CTC_E_NONE;
}

